Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem:
$context['mode'] is required to be 'form' or 'render' when calling addressfield_generate() which in-turn calls addressfield_format_address_generate() with the same requirement. This causes undefined index errors.
Solution:
$context['mode'] needs to either be checked before a comparison or $context array needs to be changed to a required argument.
Related to http://drupal.org/node/1664378
Comment | File | Size | Author |
---|---|---|---|
#1 | 1678800-require_context_array.patch | 591 bytes | andyg5000 |
#1 | 1678800-check_mode_index_before_comparison.patch | 582 bytes | andyg5000 |
Comments
Comment #1
andyg5000Patches for either solution preferred attached
Comment #2
rooby CreditAttribution: rooby commentedMarked #1664378: Notice: Undefined index: mode in addressfield_format_address_generate() (line 357 of address.inc) as duplicate of this issue.
Comment #3
SocialNicheGuru CreditAttribution: SocialNicheGuru commentederror in 1678800-require_context_array.patch
PHP Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /var/aegir/platforms/7/modules/all/addressfield/addressfield.module on line 127
Comment #4
hass CreditAttribution: hass commentedComment #5
rszrama CreditAttribution: rszrama commentedGood find, Andy. It looks like the intent of the function was to default to 'render' if a valid mode wasn't given. Since I'm hesitant to change the function signature without really knowing how many other modules that might break, I'm just going to update the docs for the function and initialize the mode in the context array if it isn't present. I've also made the if ... else statement explicitly check for the 'render' mode.
Commit: http://drupalcode.org/project/addressfield.git/commitdiff/fc2ef44