I'm using the latest version of Open Publish. As I was building the site, it was working without errors, but when I moved it from dev to production this error came up after saving articles.

    warning: Parameter 2 to calais_tagmods_calais_preprocess() expected to be a reference, value given in /home/scvbj/domains/www.scvbj.com/prod/includes/module.inc on line 483.
    warning: Parameter 1 to calais_calais_preprocess() expected to be a reference, value given in /home/scvbj/domains/www.scvbj.com/prod/includes/module.inc on line 483.

What do I need to do to get rid of these errors?

Thank you,
Joe

Comments

DickSwart’s picture

Version: 6.x-3.5 » 6.x-3.x-dev
Component: Miscellaneous » Code

Don't know if this is related but get a simmilar error:

    warning: Parameter 2 to calais_tagmods_calais_preprocess() expected to be a reference, value given in /home/sahostel/public_html/includes/module.inc on line 482.
    warning: Parameter 1 to calais_calais_preprocess() expected to be a reference, value given in /home/sahostel/public_html/includes/module.inc on line 482.
freelock’s picture

Issue tags: +PHP 5.3 compatibility

These are related to PHP 5.3, strict error logging.

hokuspokus’s picture

Can you elaborate? Is this an actual error or is it something that can be ignored and switched off somehow?

freelock’s picture

These errors are because either the hook APIs are implemented incorrectly (requiring a variable to be passed by reference when it's not necessary) or called incorrectly (with a value instead of a variable).

If the variable isn't changed inside the function that's throwing the error, you can get by by simply removing the & in the argument list. E.g. for calais_calais_preprocess, I searched for the function and changes as follows:

1. grep "function calais_calais_preprocess" -r sites/all/modules
2. (found it in sites/all/modules/opencalais/calais.module, line 346):

function calais_calais_preprocess(&$node, &$keywords) {

3. Checked to see if either $node or $keywords gets modified in this function. $node doesn't get used at all, and $keywords is just used in a for loop but not changed.
4. In this case, it's safe to remove the & in front of each parameter to get rid of the message:

function calais_calais_preprocess($node, $keywords) {

... That doesn't mean this is the right solution. The question is, should the hook_calais_preprocess functions be allowed to change what's in $node or $keywords? If not, this is the correct solution -- get rid of the & which tells PHP to modify the actual variable passed in instead of copying it. If so, this is the wrong solution -- would need to step through the code to see who is invoking this hook without passing an actual variable that can be modified.

Note that if $node is a node object, it's passed by reference anyway -- since PHP 5.0, all objects are passed by reference without needing the &. So it's probably safe to remove the & in front of $node (which is the one throwing an error, in this case).

ElusiveMind’s picture

Issue summary: View changes

This is a PHP version issue.

In PHP 5.3 make it so you do not have to include the reference indicator at call time. This is handled by the hook or function. In older versions of PHP, the opposite was the case and there was no real graceful transition. My suggestion would be to make sure you are on at least PHP 5.2.5 and see if this problem persists. I cannot reproduce the problem, so I am going to close this as cannot reproduce and believe it is due to PHP versioning issues.

ElusiveMind’s picture

Status: Active » Closed (cannot reproduce)