If you try to clear the AliasManager cache for the root path / then PHP will raise a warning: array_key_exists(): The first argument should be either a string or an integer AliasWhitelist.php:95
The reason for this is that strtok('/', '/') will return FALSE.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | interdiff_17-29.txt | 1.22 KB | sahil.goyal |
| #29 | 2939397-29.patch | 2.39 KB | sahil.goyal |
| #20 | 2939397-nr-bot.txt | 144 bytes | needs-review-queue-bot |
| #17 | interdiff-2939397-16_17.txt | 646 bytes | gauravvvv |
| #17 | 2939397-17.patch | 2.32 KB | gauravvvv |
Issue fork drupal-2939397
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kasperg commentedHere is a patch that tries to address this issue.
The patch treats
/as a special case which seems to be the same approach taken elsewhere within the class.Comment #3
kasperg commentedComment #5
kasperg commentedAnother attempt which should fix the test case.
Comment #7
kasperg commentedComment #8
dawehnerIt would be nice to document why we need to do this extra check for
Comment #9
kasperg commented#8: I also thought about that.
From one perspective I think it is already explained within the current comment:
Obviously, the path
/does not have a top-level component and if you know howstrtok()works, you will also know that it is this situation may return a boolean. Non-string arguments will makeAliasWhitelistproduce a warning. Also the same approach is used elsewhere in the AliasManager.On the other hand, it was my first encounter with
strtok()and the current issue points to the fact that it is not trivial. You could use other forms of string manipulation likesubstr()+strpos()or regular expressions but that seems cumbersome as well.I tried to rework the two places the function is used in this patch.
Comment #11
jwilson3Re-roll for Drupal 8.8+ where AliasManagerTest.php was moved from a sub-system of core into the new path_alias core module.
I agree with @kasperg's reasoning for why adding additional documentation to single out
$path !== '/'is not really necessary, and I think the new code with existing comment will be well understood.Comment #13
meladawy commentedThis should be compatible with 9.2.x
Comment #16
meladawy commented9.3.x compatible patch
Comment #17
gauravvvv commentedFixed custom command failed, Attached interdiff for same. Please review
Comment #20
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #25
gauravvvv commentedUpdating attributions
Comment #29
sahil.goyal commentedUpdating the latest MR, facing some issue to fork MR so updating the patch, #17 and #22 does not seem diff so updating interdiff with 17. and made condition so trying to resolve failures.