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.
Getting the following errors running PHP 5.4:
Warning: Illegal string offset 'pathauto' in pathauto_field_attach_form() (line 300 of /sites/all/modules/pathauto/pathauto.module).
Warning: Illegal string offset 'pathauto' in pathauto_field_attach_form() (line 319 of /sites/all/modules/pathauto/pathauto.module).
Warning: Illegal string offset 'pathauto' in pathauto_field_attach_form() (line 329 of /sites/all/modules/pathauto/pathauto.module).
Comment | File | Size | Author |
---|---|---|---|
#15 | illegalstringoffset-1580466-15.patch | 894 bytes | masipila |
#8 | openatrium-with-php5-5--1580466.patch | 1.64 KB | sobi3ch |
#7 | illegalstringoffset-1580466-6.patch | 1022 bytes | Ignigena |
#6 | pathauto.module.zip | 6.78 KB | hoebekewim |
#4 | illegalstringoffset-1580466-4.patch | 824 bytes | Ignigena |
Comments
Comment #1
Ignigena CreditAttribution: Ignigena commentedI was able to surpress the errors by changing the function at line 294 to the following. It's not the most clean or compact code and I can't guarantee it's a good solve but hopefully this helps figure out the issue:
NEW (starts at line 294 of pathauto.module)
OLD (starts at line 294 of pathauto.module)
Comment #2
Ignigena CreditAttribution: Ignigena commentedIt seems like $entity->path is sometimes a string not an array which is what is causing the warnings in PHP 5.4. I've attached a patch against the latest dev branch with my solution above cleaned up a tiny bit. I'm sure there's a more "proper" way of fixing this, so feel free to point out anything I've done wrong. Hopefully this at least helps push the issue along.
Comment #4
Ignigena CreditAttribution: Ignigena commentedTrying again ... sorry.
Comment #6
hoebekewim CreditAttribution: hoebekewim commentedI don't know if this is the correct solution but it seems to fix the error:
Line 294 in pathauto.module:
I've placed my pathauto.module file in the annex.
Comment #7
Ignigena CreditAttribution: Ignigena commentedGood call hoebekewim on the addition of the isset check. Addressed a few minor coding standards issues and rolled this into a patch, attached below.
Comment #8
sobi3ch CreditAttribution: sobi3ch commentedI don't know this is useful but I'm adding patch that's working with Warning message in PHP 5.5 with openatrium 1.12
openatrium-with-php5-5--1580466.patch (1.64 KB)
Comment #10
masipila CreditAttribution: masipila commentedPatch in comment #7 reviewed and tested. Changing status to RTBC.
Comment #11
DamienMcKennaComment #12
Dave ReidMissing space in between if and the condition.
What are the effects of this since this is redefining $entity->path only if it's defined?
Comment #13
sobi3ch CreditAttribution: sobi3ch as a volunteer and commentedCan not apply patch from #7 on branch 7.x-1.x
Comment #14
Dave ReidComment #15
masipila CreditAttribution: masipila as a volunteer commentedThe patch from #7 does not apply anymore to the latest 7.x-1.x branch (and not to 7.x-1.3) because the line numbers have changed. Attached is a new patch that does apply to the latest dev.
@Dave Reid / comment #12:
1. The if isset coding standard is now fixed
2. I believe the reason why $entity->path is redefined is this:
Before the patch
dpm($entity->path);
After the patch
The patch ensures that $entity->path will be an array. If it has been set previously, $entity->path[0] will be the actual path and $entity->path['pathauto'] will be the result of
($path != $uri['path'] && $path == $pathauto_alias)
. As a result, the'#default_value' => $entity->path['pathauto']
will not throw an illegal offset warning.edit: fixed the version from 1.4 to 1.3 in the beginning. I meant to say that the patch #7 did not apply to 1.3.