Problem/Motivation

After Kint 2.3.0+ installation (with configurable helpers from https://git.drupalcode.org/project/kint/-/merge_requests/12/diffs) each time caches are cleared from the admin UI, the following warning is shown:
Only local images are allowed.

This warning appears even though the helper functions (`d()` and `s()`) are working correctly and were successfully registered.

Steps to reproduce

- Install and enable Kint (2.3.0 or later)
- Clear all caches either from admin toolbar or from /admin/config/development/performance
- Refresh page and you will see the warning message displayed on the page

Proposed resolution

If not mistaken, HelperManager tries to re-register helper functions after cache clear. As functions already exists from initial bootstrap, \DomainException is thrown.

Proposed fix is to check if the function is already registered in Kint::$aliases before throwing the \DomainException

Patch

See attached patch file.

Comments

mitrpaka created an issue. See original summary.

mitrpaka’s picture

Issue summary: View changes
Status: Active » Needs review
jnvsor’s picture

Good idea, but since Kint::$aliases isn't keyed by helper name I'll add a static property to hold the info. I was able to reproduce this in update.php before but thought it wasn't worth fixing, but now I can't reproduce it at all and I'm very confused.

Anyway, manually reconstructed it to trigger the error and confirm it's fixed. Can you try the wip-test branch and confirm it's fixed for you?

mitrpaka’s picture

@jnvsor Thank you for the quick reply and updated fix-proposal. I can confirm the wip-test branch resolves the issue.

> I was able to reproduce this in update.php before but thought it wasn't worth fixing, but now I can't reproduce it at all and I'm very confused.

Also tried this on vanilla Drupal installation and was not able to reproduce it either. Then I did backtrace this to figure out why HelperManager is constructed second time and in our case culprit was hook_entity_load() implementation in our custom code.

Happens also when new module is enabled from admin UI (/admin/modules).

anybody’s picture

I can also confirm I get this issue after upgrading Core to 11.3.2

The following helpers could not be defined: d, kint, s

Is a tagged release planned?

jnvsor’s picture

Status: Needs review » Fixed

Released in 2.3.3.

I was hoping I could get more info on #3567569 and release them together but I guess not

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.

anybody’s picture

Thank you @jnvsor!! :)

Status: Fixed » Closed (fixed)

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