Problem/Motivation

When Drupal is set to maintenance mode, the following fatal error occurs:
TypeError: Argument 1 passed to Drupal\Core\Extension\ThemeHandler::addTheme() must be an instance of Drupal\Core\Extension\Extension, null given

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3218085

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fathima.asmat created an issue. See original summary.

fathima.asmat’s picture

Assigned: fathima.asmat » Unassigned
Status: Active » Needs review
FileSize
1.16 KB

This patch should fix it.

fathima.asmat’s picture

Status: Needs review » Needs work
fathima.asmat’s picture

cilefen’s picture

As far as I know this doesn't actually happen normally. How do we reproduce this one?

fathima.asmat’s picture

Status: Needs work » Needs review
fathima.asmat’s picture

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Kristen Pol’s picture

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

@fathima.asmat Would you provide more detailed steps to reproduce along with more information such as the Drupal version and any contributed modules you have installed. I agree with #6 that this is not a typical error so there may be something about your setup that is causing this.

x775’s picture

I encountered this obscure problem, too.

The issue arose attempting to upgrade a website from Drupal 8.8 to 9.3. Due to a number of other issues, the website was in maintenance mode when the upgrade was attempted. Subsequent database upgrades and module updates were carried out using drush. Attempting to access the website directly throws the following:

- -  18/May/2022:13:06:04 +0000 "GET /index.php" 500
NOTICE: PHP message: TypeError: Argument 1 passed to Drupal\Core\Extension\ThemeHandler::addTheme() must be an instance of Drupal\Core\Extension\Extension, null given, called in /app/web/core/includes/theme.maintenance.inc on line 93 in /app/web/core/lib/Drupal/Core/Extension/ThemeHandler.php on line 82 #0 /app/web/core/includes/theme.maintenance.inc(93): Drupal\Core\Extension\ThemeHandler->addTheme(NULL)
#1 /app/web/core/includes/bootstrap.inc(505): _drupal_maintenance_theme()
#2 /app/web/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php(121): drupal_maintenance_theme()
#3 [internal function]: Drupal\Core\EventSubscriber\MaintenanceModeSubscriber->onKernelRequestMaintenance(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#4 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#5 /app/vendor/symfony/http-kernel/HttpKernel.php(134): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\RequestEvent), 'kernel.request')
#6 /app/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#7 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /app/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#17 {main}

However, by forcing the website to leave maintenance mode by executing

drush sset system.maintenance_mode 0

I get another error, indicating that the base theme of customised theme is missing. In any event, applying the patch allows me to skip directly to the error concerning the customised theme.

cilefen’s picture

What is the value of $settings['maintenance_theme'] in settings.php?

This error indicates there is a maintenance theme set with an undefined ancestor (base) theme.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dmezquia’s picture

I have the same error, but patch #8 doesn't work for me. Drupal 9.4.8.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nofue’s picture

@cilefen is right with #12: watch that setting before patching stuff.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.