Line 1794 of patterns.module is throwing a call-time-pass-by-reference warning at each page load. It doesn't look like you really need that pass-by-reference on $ref[i++], because $ref is already being passed by reference inside the array('trace' => _patterns_array_trace($ref)) in the line above.

I removed it, and it doesn't seem to be causing any problems. Want a patch?

Comments

vaish’s picture

It seems to me that pass-by-reference is not required (I'm looking at the line 1850 in the current version) because parameters to array_unshift() are already passed by reference. However, this piece of code is recently added by Sarva and it's currently used only by views component, so maybe he could confirm that everything is fine before we remove it.

sarvab’s picture

I guess different versions of php5 allow passing in references in through array_unshift while others do not.

I'm not actually 100% sure if the reference needs to be kept there or not, but I'd like to stay on the safe side and keep it as a reference because the various keys (such as 'parent' => &$ref) pointing to different parts of the context structure could potentially get messed up if we don't.

Also, from what I've tested, array_unshift does not push variables as reference to the front of the array. I ran a little test to check that, and it was a copy of the variable instead of a reference unfortunately.

I just committed a fix that will keep things how they were but get rid of the error.

sarvab’s picture

Status: Active » Fixed
senpai’s picture

#2 fix was tested by me, and working just fine. No PHP warnings. Cool!

Status: Fixed » Closed (fixed)

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