The following notice is raised when using E_STRICT when testing:

Only variables should be passed by reference

The attached patch resolves this error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Needs review » Needs work
chx@veyron:/var/www/7$ php -r 'error_reporting(E_ALL|E_STRICT);function x() { return array();} reset(x());'
PHP Strict standards:  Only variables should be passed by reference in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
chx@veyron:/var/www/7$ php -r 'error_reporting(E_ALL);function x() { return array();} reset(x());'
chx@veyron:/var/www/7$ 

Confirmed. While the code is the correct fix for this kind of error, we need a comment here to indicate why the --seemingly unncessary-- variable.

rfw’s picture

Status: Needs work » Needs review
FileSize
738 bytes

Added a comment about why temporary storage in a variable is required.

chx’s picture

  • Welcome to core patching
  • You forgot the dot from the end of sentence
  • I would move the comment one line up
  • You can't pass in a reference, Warning: Call-time pass-by-reference has been deprecated would result, the comment needs to be something akin to "We need an extra variable here because reset takes its argument by reference and passing in a constant emits a notice in strict mode"
  • dont forget to break at column 80.
rfw’s picture

FileSize
948 bytes

Amended comment.

rfw’s picture

FileSize
940 bytes

Whoops, git diff prefices.

dww’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.09 KB

Re-rolled to make the comment wrap to 80 characters, to use () after function names for clarity, and to do some minor tweaks to the text to make it read more clearly.

Since it's only nitpicks on the comment, even though it's my patch, I'm just going to RTBC it. ;)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)

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