I get this error when I edit an entity with an AddressField field:

String warning: Only variables should be passed by reference in addressfield_format_address_generate() (line 319 of sites/all/modules/contrib/addressfield/plugins/format/address.inc

That's the following line:

    // Remove the prefix from the first widget of the block.
    $first_child = reset(element_children($format['locality_block']));

Comments

damienmckenna’s picture

Title: reset() function called on array element in addressfield_format_address_generate() » reset() function incorrectly called in addressfield_format_address_generate()
Version: 7.x-1.x-dev » 7.x-1.0-beta1
Status: Active » Needs review
StatusFileSize
new658 bytes

According to the PHP docs the reset() function accepts a single argument as a reference, thus you can't daisy chain the returned data from element_children() to it. This patch should resolve the problem.

FYI the problem exists on line 338 in the current dev branch.

damienmckenna’s picture

StatusFileSize
new1.11 KB

Turns out there was a second instance of the same statement elsewhere in the same file.

Rich_Weiss’s picture

I am getting the same error message. I did a fresh install of xampp and then installed commerce_kickstart-7.x-1.0-beta6-core. I then added one product to the shopping cart and tried to check out, at which point I received the error message. After patching the address.inc the error did not reappear, and I could complete the checkout process.

damien tournoud’s picture

Status: Needs review » Fixed

Thanks for the patch, committed.

Status: Fixed » Closed (fixed)

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