Uninstalled custom theme stuck in config blocking config import

Created on 29 July 2017, over 7 years ago
Updated 8 November 2023, about 1 year ago

Problem/Motivation

During an attempted drush cim, I get the following error messages:

array_keys() expects parameter 1 to be array, null given ConfigImportSubscriber.php:173 [warning]
Invalid argument supplied for foreach() ConfigImportSubscriber.php:173

and

exception 'InvalidArgumentException' with message 'Unknown theme: w2w.' in [error]
/Users/rppowell/Sites/women2women/core/lib/Drupal/Core/Extension/ThemeInstaller.php:220

This theme has been uninstalled but it looks like it has gotten stuck in config. I have tried different strategies to find the corrupt data but so far no luck. Here are some suggestions from people in slack channel and various pages which I have tried.

  • Confirmed theme was uninstalled
  • Searched config files for dependencies to the theme
    • Ran queries to check database
    • select * from key_value where collection = 'state' and name = 'system.theme.files';
    • select name from config where name like ('%theme%');

Using xdebug I have determined that these lines are what are retrieving the corrupt data.

ConfigImportSubscriber.php#171

$uninstalls = $config_importer->getExtensionChangelist('theme', 'uninstall');

ThemeInstaller.php#214

public function uninstall(array $theme_list) {

I cannot determine what calls uninstall but it is after the batch kicks off. Just to clarify, if I do a drush cex w2w is listed under themes. If I try to delete that record and drush cim I will get this error. I would love it if someone could clarify how $config_importer is getting the theme name.

Unfortunately, I am at the point where I don't know how else to troubleshoot this and am starting to get really opinionated about why I don't think a deleted theme should break CIM. I will supply a patch on whatever work-around I commit to but really hoping to learn how to fix this the right way.

Proposed resolution

Two solutions:

  1. In ConfigImportSubscriber, check if key exist before foreach
  2. In ThemeInstaller.php, if the key is the known bad theme, return

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
ConfigurationΒ  β†’

Last updated about 17 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States robpowell Boston

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024