Problem/Motivation

The patch in issue 3380953 has introduced a new issue.

if ($url->isExternal() || !$original_link->getUrlObject()->isRouted()) {
$original_link is null.

Error: Call to a member function getUrlObject() on null in admin_toolbar_links_access_filter_filter_non_accessible_links() (line 84 of modules/contrib/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module).

CommentFileSizeAuthor
original-link-null.patch795 bytesrteijeiro
Command icon 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

rteijeiro created an issue. See original summary.

dydave made their first commit to this issue’s fork.

dydave’s picture

Thanks a lot Ruben (@rteijeiro) for your help on this issue, it's greatly appreciated! 🙂

The changes suggested in the patch in the issue summary have been added to the merge request MR !159 👌

To be honest, I did not test this directly myself, since I'm not really using the admin_toolbar_links_access_filter module anymore...

I think it was marked deprecated and supposed to be removed when future releases drop support for core versions below 10.3.
So personally, I wouldn't really be interested in working on this, but I would not be opposed to getting this added to the module.

If you could please help testing and reviewing the changes in the MR and if you think they could provide an acceptable solution, then I would be glad to get these changes merged in.

Again, since we're looking at removing this module, we wouldn't be bothering with Tests, docs and such. But if getting this patch committed could help with your projects, we would certainly be glad to do so 🙂

We would greatly appreciate if you could please try testing merge request MR !159 and give us your feedback or reviews.

Feel free to let me know if you spot anything or if I missed anything else in the comments above, I would certainly be glad to help.
Thanks in advance!

benstallings changed the visibility of the branch 3528054-originallink-is-null to hidden.

benstallings changed the visibility of the branch 3528054-originallink-is-null to active.

benstallings’s picture

Status: Needs review » Reviewed & tested by the community

This looks correct to me! I also ran it past Claude Code, which said,

The fix is correct and straightforward. The code is inside the elseif (!empty($item['url'])) branch (line 81), which is the fallback path when $item['original_link'] is empty. The old code referenced $original_link here — a variable that is only assigned inside the if (!empty($item['original_link'])) block (line 71-73). So $original_link would be undefined/null in this branch, causing a fatal error.

The fix correctly uses $url (which is guaranteed to be set in this branch) instead of $original_link->getUrlObject(). Both expressions serve the same purpose — checking whether the URL is routed — so the behavior is preserved while eliminating the null reference.

Verdict: Clean, minimal, correct fix. The @phpstan-ignore variable.undefined comment on the line above (line 84) was likely added to suppress the static analysis warning about this exact issue rather than fixing the root cause — this commit resolves the actual bug. That suppression comment is now unnecessary, though removing it is a separate concern. Good to merge.

  • dydave committed 28a6dfd1 on 3.x
    Issue #3528054 by almunnings, rteijeiro, dydave: Fixed regression...
dydave’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: +#3569351: Drop support for Drupal 10.2 and below

Thanks a lot Ben (@benstallings) for updating this issue and sharing your testing feedback! 🙏

Following your confirmation, I rebased the merge request, which triggered a build that indeed, returned a phpstan error for the unnecessary inline phpstan ignore comment, as suggested by the AI. 👍

After removing the line, all jobs seemed to pass 🟢 for the core versions currently supported.
Jobs failing for next minor or major are not specific to this MR and failing on the 3.x branch anyway.

Therefore, I went ahead and merged the changes above at #8 🥳

In any case, all the code of submodule admin_toolbar_links_access_filter should be removed in #3569351: Drop support for Drupal 10.2 and below, since the feature was integrated in Drupal core.

Since I couldn't think of any other actions or follow-up tasks to be carried in this ticket, marking it as Fixed, for now.

Feel free to let us know if you have any questions or concerns on any of the changes committed in this issue or the project in general, we would surely be glad to help.
Thanks again for your contributions and interest in the module. 😊

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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