After upgrading to php 5.3 I get the following error on the search results page:

warning: Parameter 1 to comment_nodeapi() expected to be a reference, value given in [drupal path]/drupal-6.14/includes/module.inc on line 450.

Comments

drasgardian’s picture

Issue tags: +PHP 5.3

For the time being I have simply changed comment.module and removed "&" from this line:

function comment_nodeapi(&$node, $op, $arg = 0) {

Looking forward to a cleaner solution that doesn't involve me editing core.

This bug doesn't seem to be related to any other modules or themes that are installed. I'm running drupal 6.14 and php 5.3 on centos 5.3.

infojunkie’s picture

subscribe, same config

mot’s picture

We have a standard XAMPP installation here which ships with php 5.3 as well. I get the error message(s) only when a search term is found. You get one error message per node found. E.g. if your term is found in 4 nodes, you get 4 times the error.

pimentoski’s picture

i have the same problem. php 5.3 + drupal 6.14 in xampp the fix posted by drasgardian works for me.

obelus’s picture

Hi, I have the same problem, like drasgardian had described. The same warning wrote me drupal after searching. If searching something find it write the results and same count of mentioned warnings (warning: Parameter 1 to comment_nodeapi() expected to be a reference, value given in [drupal path]/drupal-6.14/includes/module.inc on line 450.) like the count of results. If searching is without results, no warning is written.

For this time, I make the same like drasgardian did. Its ok now, but like he wrote, it is not "clear" if we have to edit core.

Thank you for new tips and advices.

nicksanta’s picture

What action are you guys performing to get this error? I'm using php 5.3.0, and i can't replicate this problem by creating, editing or deleting a comment. I've also tried creating, editing and deleting nodes, modifying the comment settings etc.. and cant get it to happen.

silviucostiniuc’s picture

Yep the same problem to me. When running a search, if it finds any result, it shows the result but also the warning:
Parameter 1 to comment_nodeapi() expected to be a reference, value given in .

I'm also using the last version of XAMPP (that comes ) with PHP 5.3.

I think this is not the single problem ON PHP 5.3 concerning the "references". For the Views module there is also a "reference problem".

You can view the topic here:

http://drupal.org/node/452384 (Make Views compatible with PHP 5.3)

liam mcdermott’s picture

@nickurbits: it's searching that causes the problem, specifically the search results page when using core's search.module. It seems the error is generated once per search result.

pirna’s picture

Version: 6.14 » 6.15

After update to drupal 6.15 I get the same error (after a search).

warning: Parameter 1 to comment_nodeapi() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 462.

yhager’s picture

Priority: Normal » Critical

subscribing.

The "fix" in #1 is not good, since comment_nodeapi expects the value to be a reference, but the caller, which uses call_user_func_array can only send values.

I think it is ok to change this to critical since it means that comment_nodeapi() does not function well on PHP 5.3 environments.

berdir’s picture

The function definition needs to be as it is to keep compatibility with PHP 4.

Something (I suspect a contrib or even custom module) is calling the hook in a wrong way. I've explained how to figure out *who* that is at #360605-198: PHP 5.3 Compatibility. You just need to place those 3 php lines at the top of the comment_nodeapi() function. When the error happens, it should display how that function was called and by whom. Feel free to post the whole output here and I'll help to determine which module is doing something wrong ;)

yhager’s picture

The tip in #360605-198: PHP 5.3 Compatibility did not help by itself, since there is no indication inside comment_nodeapi that there is a problem. I implemented something along these lines in drupal_error_handler, adding the following:

    if (strstr($entry, 'comment_nodeapi')) {
      print ($entry);
      xdebug_print_function_stack();
      die();
    }    

The output I received after performing a search was:

warning: Parameter 1 to comment_nodeapi() expected to be a reference, value given in /var/www/html/includes/module.inc on line 450.
( ! ) Xdebug: user triggered in /var/www/html/includes/common.inc on line 646
Call Stack
#	Time	Memory	Function	Location
1	0.0003	329416	{main}( )	../index.php:0
2	0.1583	15673844	menu_execute_active_handler( ??? )	../index.php:18
3	0.1599	15712804	call_user_func_array ( string(11), array(1) )	../menu.inc:348
4	0.1599	15713056	search_view( string(4) )	../menu.inc:0
5	0.1695	16535160	search_data( string(4), string(4) )	../search.pages.inc:32
6	0.1695	16535312	module_invoke( string(4), string(6), string(6), string(4) )	../search.module:1160
7	0.1695	16536024	call_user_func_array ( string(11), array(2) )	../module.inc:450
8	0.1695	16536340	node_search( string(6), string(4) )	../module.inc:0
9	0.4757	20102512	module_invoke( string(7), string(7), object(stdClass)[16], string(12) )	../node.module:1283
10	0.4757	20103204	call_user_func_array ( string(15), array(2) )	../module.inc:450
11	0.4757	20104620	drupal_error_handler( long, string(72), string(56), long, array(4) )	../module.inc:0
12	0.4757	20106924	xdebug_print_function_stack ( )	../common.inc:646

The problem is with using call_user_func_array to pass values by reference, see comment #10 above.

berdir’s picture

StatusFileSize
new1.02 KB
new1.02 KB

The problem is with using call_user_func_array to pass values by reference, see comment #10 above.

Just for the reference, it is possible to use call by reference with call_user_func_array, you have to the single $param entries by reference. See http://drupal.org/drupal_execute for an example.

However, the code that does trigger only calls comment and taxonomy with module_invoke (which I find more than ugly., but that's not the topic of this issue :)). The attached patch changes these calls to normal function calls. Should work with that.

berdir’s picture

Status: Active » Needs review

Hm. something wrent wrong :)

yhager’s picture

StatusFileSize
new1.02 KB

Fixed a typo in the previous patch. works for me.

tovstiadi’s picture

subscribe

Status: Needs review » Needs work

The last submitted patch, node_search_php53_fix.patch, failed testing.

ti2m’s picture

great, thanks a lot, seems to fix the issue for me

thtas’s picture

subscribing

yhager’s picture

Status: Needs work » Needs review

Can anybody explain why the bot fails the patch? I went to the error log, and ran the same 'patch' command as the bot did, and it worked. So what needs to be done here exactly?

$ wget http://drupal.org/files/issues/node_search_php53_fix_1.patch -O /tmp/node_search_php53_fix_1.patch
$ patch -p0 -i /tmp/node_search_php53_fix_1.patch
patching file modules/node/node.module
Hunk #1 succeeded at 1282 (offset 2 lines).

gcclinux’s picture

Version: 6.15 » 6.14

same error version:

drupal 6.14 and php 5.3.1 running mandriva 2010

yhager’s picture

@gcclinux - can you try the patch above?

gcclinux’s picture

all fixed.... thanks

janspeer’s picture

same error,
but I access my site via the webbrowser or ftp, how can I repair this,
I dont think I can run a patch
can i do the change manual ? pls explain how.
thanks

attishu’s picture

subscribing

Anonymous’s picture

patch worked fine for me 6.15 drupal core

dooug’s picture

subscribe

Catx’s picture

I see same problem in my site. In addition more like user_reference . . Error error. Where the owner of drupal? Why not make module.inc complete error free for php 5.2. Why patch? I dont know here many people. No one here to make perfect module.inc Only 1 file headche in site. Please team make it before drupal7. I wait for complete file.

Catx’s picture

I see same problem in my site. In addition more like user_reference . . Error error. Where the owner of drupal? Why not make module.inc complete error free for php 5.2. Why patch? I dont know here many people. No one here to make perfect module.inc Only 1 file headche in site. Please team make it before drupal7. I wait for complete file.

Catx’s picture

I try all thing. In 2 patch only difference
1. if (module_exists('taxonomy')) (
2. if (module_enabled('taxonomy')) (
In both case no work.

Catx’s picture

I put those three line in my site http://surf3d.com Check what happen. Site open from desktop but disappear from mobile surf. Tell me what i do next.

mikejonesok’s picture

Update for Drupal 6.16?

berdir’s picture

Version: 6.14 » 6.x-dev

Patch applies fine on 6.x-dev for me and should do so on 6.16...

berdir’s picture

#15: node_search_php53_fix.patch queued for re-testing.

yasser1820’s picture

Component: comment.module » node.module
Assigned: Unassigned » yasser1820

i have the same problem when i make a search in my site : warning: Parameter 1 to comment_nodeapi() expected to be a reference

what can i do ??? pls need help .

i have php 5.3 .. apache server ... ( i am working on Xampp)

i downloaded Drupal 6.16 ..and every thing is up to date ....

yasser1820’s picture

i found a solution that worked for me ..... i was enabling the Comment module .... in the modules >> core options >> Comments .... while i have no place for the users to enter comments .... i disabled it and every thing worked ... i don't receive this message any more .

i hope this can help some one ...

Brian Keller-Heikkila’s picture

The patch in #20 used to work for me in 6.15, but does not work in 6.16. Since 6.16 changed node.module, I manually applied the 2 if statements (mentioned in #30) to lines 1288 and 1290, but it does not work. 6.16 still shows the error about comment_nodeapi.

The only way I can get rid of the error messages is to comment out lines 1288 and 1290 of node.module. This is definitely not ideal since it removes functionality from the search, but with a live site, we cannot have error messages showing.

Anyone know how to fix properly for 6.16?

francisconi.org’s picture

I solved simply by replacing in /modules/comment/comment.module

function comment_nodeapi(&$node, $op, $arg = 0) {

by:

function comment_nodeapi($node, $op, $arg = 0) {

which is what Mr. drasgardian proposed that the application of the patch did not work and node_search_php53_fix.patch spoiling me

berdir’s picture

That change would break PHP4 compatibility and is therefore not possible.

I'll try to patch to see if there are any additional errors soon.

DaveX’s picture

Is there a solution?

I have the same problem. I use PHP 5.3.1 an Drupal 6.16

ayalsule’s picture

subscribe

6.16 + 5.3.1

there is a lot of problems with 5.3

ayalsule’s picture

what about 6.16?
no solution?

DaveX’s picture

Is a patch available? (PHP 5.3.1, Drupal 6.16)

On my site the search function is essential. With the errors it is not usable, it is confusing. :-(

fblevins’s picture

I got the same thing. I'm new to Drupal and have the most recent stable versions of Drupal and PHP running. Thought I'd messed something up somewhere down the line but now see that this is a real issue. Not a problem right now because I'm just learning, but it would be nice if this got fixed somewhere down the line (wish I could just fix it for everyone, but I'm such a NOOB)!!!

francisconi.org’s picture

StatusFileSize
new489 bytes

I agree with what he says Mr. Berdan

But if you use PHP 5.3 (and do not plan to reuse PHP 4), the solution (at least it is temporary)

I solved simply by replacing in /modules/comment/comment.module

function comment_nodeapi(&$node, $op, $arg = 0) {

by:

function comment_nodeapi($node, $op, $arg = 0) {

janspeer’s picture

I have set in admin the selection "log to file" and not "log to file and screen" and then you don't see the warnings anymore

berdir’s picture

The patch from yhager in #15 still works fine in 6.16, so just use that one. I can't RTBC it since I pretty much wrote the patch, but maybe someone else can.. ;)

virtualmcube’s picture

patch worked fine for me, i am running my site with drupal 6.15...

b3liev3’s picture

The patch works. It's the same with all the php 5.3 issues.

jimrockford’s picture

Me: PHP 5.3.1 and Drupal 6.16

node_search_php53_fix.patch from #15 had no effect in resolving error message

#1 & #38 suggestion did fix the issue.

Looking at function body for comment_nodeapi(), the only part where the node appears to be modified, and therefore ref vs obj _is_ important, is in the "prepare" case. It contains:
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);

What's the importance of that line?

All other references to $node in the function appear to only be reads, so it wouldn't really matter (as much) if it's an object (value) or a reference.

Hack core, cross fingers :D

berdir’s picture

If the patch doesn't work, then a different function calls it wrong, so please post the whole eror message.

Max K.’s picture

2nding #50 -- the "prepare" case cannot be ignored.

verta’s picture

subscribing (using 6.16)

ar-jan’s picture

I got this warning too in Drupal 6.16 after migrating to PHP 5.3, when searching for a term.

warning: Parameter 1 to comment_nodeapi() expected to be a reference, value given in /includes/module.inc on line 462.

I applied the patch in #15 on a D6.16 site.

patch -p0 < node_search_php53_fix_1.patch
patching file modules/node/node.module
Hunk #1 succeeded at 1285 (offset 5 lines).

Searching no longer throws a warning so that's worth something ;). I don't know enough to comment on whether this is a proper solution.

n4rky’s picture

Re #20: I never understand what directory I'm supposed to be in when I apply these patches. Changing to the directory with the actual file and "patch < /tmp/node_search_php53_fix_1.patch" worked for me.

holydrupal’s picture

works fine for me 2

yan’s picture

Same problem running Drupal 6.16 with PHP 5.3.2-1ubuntu4. Patch from #15 solves it.

Einstein27’s picture

#13: node_search_php53_fix.patch queued for re-testing.

tbm13’s picture

Patch #15 fixes the problem for me too.

Why has this patch not been reviewed and applied yet?

heine’s picture

Assigned: yasser1820 » Unassigned

Why has this patch not been reviewed and applied yet?

Because no-one has reviewed it. All these PHP 5.3 issues collect are inane comments.

The good news is that everyone can review patches. See http://drupal.org/patch/review for a guide.

Reg’s picture

Subscribing

Reg’s picture

It may be more appropriate (and is self-documenting) to address the version conflict more directly with something like below.

This is just an idea for discussion and not tested because I don't have this particular problem but if someone can
test it that would be great. I am interested because it might become a problem since I have PHP 5.3 running and
do have similar problems I am working on.

#
# Make this a function since it will likely be used in other places if used at all.
#
function drupal_php_version_53_plus() {
    static $new_vers = NULL;
    if (is_null($new_vers)) {
        $new_vers = (version_compare(phpversion(), '5.3.0') >= 0); # returns true if version 5.3.0+
    }
    return $new_vers;
}

#
# Add a calling layer to handle PHP version conflicts
#
if (drupal_php_version_53_plus()) {
    # Executed in PHP versions 5.3+
    function comment_nodeapi($node, $op, $arg = 0) { # No "&" to avoid warnings
        return _comment_nodeapi(&$node, $op, $arg = 0);
    }
} else {
    # Executed in PHP versions prior to 5.3
    function comment_nodeapi(&$node, $op, $arg = 0) {
        return _comment_nodeapi(&$node, $op, $arg = 0);
    }
}

#
# The actual function now with a preceding underscore since it should no longer be called directly
#
function _comment_nodeapi(&$node, $op, $arg = 0) {
    ...
}
berdir’s picture

Please not again.... :)

- The current code is *wrong*, it does not work correctly in PHP 5.2 either, PHP 5.2 just silently ignores the by reference and uses the parameter as by value. There are no resulting bugs/issues here in 5.2 since $node is not changed with the used $op but it is wrong nevertheless.

- The patch in #15 fixes the problem and works perfectly fine for both 5.2 and 5.3, there is no need to introduce conditional function definitions and stuff like that.

Reg’s picture

If it's an existing bug and nothing to do with versions, of course, I agree.

Anonymous’s picture

I just applied the patch w/ success. Note to newbies like me: follow the example in # 20, but make sure you are in the root of your drupal installation before running the final step. Also watch out for the text-wrapping in the example; the 1st command takes up 2 lines. The 2nd command starts '$ patch -p0'

Carlos Miranda Levy’s picture

I confirm that patch #45 is still needed and works on Drupal 6.16.

Carlos Miranda Levy’s picture

Current node.module version in Drupal 6.16 is 1.947.2.22
// $Id: node.module,v 1.947.2.22 2010/03/03 21:36:37 goba Exp $

Patch 15 aims to fix v 1.947.2.19 of node.module

Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.947.2.19
diff -u -p -r1.947.2.19 node.module
--- modules/node/node.module	23 Sep 2009 09:09:30 -0000	1.947.2.19
+++ modules/node/node.module	21 Jan 2010 23:01:59 -0000

Patch 15 fails.

heine’s picture

Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

The patch in #15 still applies with Hunk #1 succeeded at 1285 (offset 5 lines). The patch in #45 makes no sense; see #63.

#15 makes sense, and works in manual tests with PHP 5.3

aaron.r.carlton’s picture

patch #15 worked for me using 6.16. Looking forward to this in the next release.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Great, thanks for testing. Committed #15!

Carlos Miranda Levy’s picture

Why and how commit when it explicitely fails?

heine’s picture

Why and how commit when it explicitely fails?

What do you mean? Per #68, the patch in #15 still applies with a fuzz.

Carlos Miranda Levy’s picture

It failed to me, the bot and others.

heine’s picture

"Failed" meaning what exactly? The patch applies and solves the issue.

The qa testbot is not working correctly for Drupal 6.

Carlos Miranda Levy’s picture

Sorry, my bad.
I downloaded a fresh install of 6.16 and patch #15 applied successfully.

patch -p0 -b < node_search_php53_fix_1.patch
patching file modules/node/node.module
Hunk #1 succeeded at 1285 (offset 5 lines).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ayalsule’s picture

#15 worked for me

klonos’s picture

Title: comment_nodeapi() errors on php 5.3 » Parameter 1 to comment_nodeapi() expected to be a reference module.inc, line 450 (php 5.3 compat)
Version: 6.x-dev » 6.19
Issue tags: -PHP 5.3 +PHP 5.3 compatibility

I still get the error in latest D6.19 (patch in #15 is included):

warning: Parameter 1 to menu_nodeapi() expected to be a reference, value given in .../includes/module.inc on line 462.

...but this time it is about menu_nodeapi() instead of comment_nodeapi(). Should I file a separate issue?

klonos’s picture

Title: Parameter 1 to comment_nodeapi() expected to be a reference module.inc, line 450 (php 5.3 compat) » Parameter 1 to comment_nodeapi() expected to be a reference module.inc, line 450 (php 5.3 compatibility)
Issue tags: +PHP 5.3
berdir’s picture

Title: Parameter 1 to comment_nodeapi() expected to be a reference module.inc, line 450 (php 5.3 compatibility) » comment_nodeapi() errors on php 5.3

That is not the same error.

Your error is related to menu_nodeapi(). That is not called like comment_nodeapi() was. This must be a contrib or even custom module that does this.

klonos’s picture

Title: comment_nodeapi() errors on php 5.3 » Parameter 1 to comment_nodeapi() expected to be a reference module.inc, line 450 (php 5.3 compatibility)
damien tournoud’s picture

Version: 6.19 » 6.x-dev
dewancodes’s picture

Yes, It works for me. Big Thanks!

astra’s picture

My site got the same problem after upgrading to php5.3:

warning: Parameter 1 to comment_nodeapi() expected to be a reference, value given in .../includes/module.inc on line 185.

Try this solution, go to comment.module and change the line (line 276 for D4.7, line 405 for D5):

function comment_nodeapi(&$node, $op, $arg = 0) {

with new one (just removed "&"):

function comment_nodeapi($node, $op, $arg = 0) {

It seems to fix this problem.