Reproduce:

1. Create CSS Injector
2. Flush caches, open page source and see the custom asset injector CSS loaded
3. Enable maintenance mode
4. Check page source, asset is not loaded

When in maintenance mode, there's new class created in the body `.maintenance-page` that we want to use with the asset injector.

Thanks

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

vibrasphere created an issue. See original summary.

  • pookmish committed e9c6d068 on 8.x-2.x
    Issue #3418928: Not working in maintenance mode
    
pookmish’s picture

Status: Active » Fixed
hswong3i’s picture

Status: Fixed » Needs work

I get following error message once fetching the latest 8.x-2.x-dev:
NOTICE: PHP message: Uncaught PHP Exception TypeError: "Drupal\Core\Render\Renderer::addCacheableDependency(): Argument #1 ($elements) must be of type array, null given, called in /var/www/html/modules/contrib/asset_injector/asset_injector.module on line 153" at /var/www/html/core/lib/Drupal/Core/Render/Renderer.php line 768

After rolling back the patch, issue get fixed:

cd /var/www/html/modules/contrib/asset_injector
curl -skL https://git.drupalcode.org/project/asset_injector/-/commit/e9c6d068752a7f152ee1d013e54eda2112daee35.patch | patch -p1 -R

hswong3i’s picture

Title: Not working in maintenance mode » Revert "Issue #3418928: Not working in maintenance mode"
Status: Needs work » Needs review
pookmish’s picture

Title: Revert "Issue #3418928: Not working in maintenance mode" » Not working in maintenance mode

@hswong3i, This sounds like you have something else going on. In the 8.x-2.x version, line 153 is a comment and the only thing added in the commit was adding a hook_preprocess_maintenance_page which works exactly like it's supposed to when using a base installation. You should debug your code first.

anybody’s picture

Status: Needs review » Postponed (maintainer needs more info)

@hswong3i any further details here? Can we set this fixed again?

hswong3i’s picture

hswong3i’s picture

StatusFileSize
new1.37 KB
pookmish’s picture

Status: Postponed (maintainer needs more info) » Fixed

I added a unit test for the maintenance mode page assets. It works as expected. @hswong3i, if your site is sending "null" into the hook_preprocess_maintenance_page then you have other things that are breaking the functionality. Even Drupal core expects an array in the hooks for claro and olivero themes.

Status: Fixed » Closed (fixed)

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