Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
After running drush cex with https://www.drupal.org/project/config_ignore/issues/3099674#38 I get this error:
$ drush cex -y
[error] TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::unsetValue() must be of the type array, null given, called in /web/modules/contrib/config_ignore/src/EventSubscriber/ConfigIgnoreEventSubscriber.php on line 150 in Drupal\Component\Utility\NestedArray::unsetValue() (line 219 of /web/core/lib/Drupal/Component/Utility/NestedArray.php) #0 /web/modules/contrib/config_ignore/src/EventSubscriber/ConfigIgnoreEventSubscriber.php(150): Drupal\Component\Utility\NestedArray::unsetValue(NULL, Array)
#1 /web/modules/contrib/config_ignore/src/EventSubscriber/ConfigIgnoreEventSubscriber.php(96): Drupal\config_ignore\EventSubscriber\ConfigIgnoreEventSubscriber->transformStorage(Object(Drupal\Core\Config\DatabaseStorage), Object(Drupal\config_filter\Config\FilteredStorage))
#2 [internal function]: Drupal\config_ignore\EventSubscriber\ConfigIgnoreEventSubscriber->onExportTransform(Object(Drupal\Core\Config\StorageTransformEvent), 'config.transfor...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#3 /web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\Core\Config\StorageTransformEvent), 'config.transfor...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#4 /web/core/lib/Drupal/Core/Config/ExportStorageManager.php(88): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('config.transfor...', Object(Drupal\Core\Config\StorageTransformEvent))
#5 /web/core/lib/Drupal/Core/Config/ManagedStorage.php(146): Drupal\Core\Config\ExportStorageManager->getStorage()
#6 /web/core/lib/Drupal/Core/Config/ManagedStorage.php(127): Drupal\Core\Config\ManagedStorage->getStorage()
#7 /web/core/lib/Drupal/Core/Config/CachedStorage.php(247): Drupal\Core\Config\ManagedStorage->getAllCollectionNames()
#8 /web/core/lib/Drupal/Core/Config/StorageComparer.php(451): Drupal\Core\Config\CachedStorage->getAllCollectionNames()
#9 /web/core/lib/Drupal/Core/Config/StorageComparer.php(198): Drupal\Core\Config\StorageComparer->getAllCollectionNames()
#10 /vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php(135): Drupal\Core\Config\StorageComparer->createChangelist()
#11 /vendor/drush/drush/src/Drupal/Commands/config/ConfigExportCommands.php(115): Drush\Drupal\Commands\config\ConfigExportCommands->doExport(Array, '../config/sync')
#12 [internal function]: Drush\Drupal\Commands\config\ConfigExportCommands->export(NULL, Array)
#13 /vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#14 /vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#15 /vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#16 /vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#17 /vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#24 /vendor/drush/drush/includes/preflight.inc(18): require('/Volumes/Webdev...')
#25 phar:///usr/local/bin/drush/bin/drush.php(141): drush_main()
#26 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#27 {main}.
TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::unsetValue() must be of the type array, null given, called in /web/modules/contrib/config_ignore/src/EventSubscriber/ConfigIgnoreEventSubscriber.php on line 150 in Drupal\Component\Utility\NestedArray::unsetValue() (line 219 of /web/core/lib/Drupal/Component/Utility/NestedArray.php).
[warning] Drush command terminated abnormally.
Seems like there's a bug here, $import_data is undefined:
$source_data = $source_storage->read($config_name);
foreach ($keys as $key) {
NestedArray::unsetValue($import_data, $key);
}
Proposed resolution
Fix the export.
Comment | File | Size | Author |
---|---|---|---|
#11 | 3117135-11.patch | 14.34 KB | claudiu.cristea |
|
Comments
Comment #2
mpp CreditAttribution: mpp at AmeXio for District09 commentedLet's see what testbot says.
Comment #3
claudiu.cristeaThank you for spotting this. This is a bug introduced by me because, initially, that variable was named
$import_data
. Then I renamed it to$source_data
and, it seems, that I forgot 2 occurrences. We only need to replace$import_data
with$source_data
. There should be no$import_data
in the code.The reason we didn't catch this is because we don't have a test case where we only ignore one ore more keys from a config, rather than ignoring the whole config. Could please extend the
ConfigWithTranslationTest
test and add another config where we only ignore some keys from that config? Also, post a "test only" patch so we that we can observe the failure.Comment #4
mpp CreditAttribution: mpp at AmeXio for District09 commented@claudiu.cristea, I had indeed noticed the commit where we refactored
$import_data
with$source_data
.Updating the patch accordingly. I'd have to look into the tests when I have some more time.
I fear that there's one (or more) regression(s) when compared to https://www.drupal.org/project/config_ignore/issues/2857247;
1. The following ignore config used to work (all layers were ignored, except 'agiv_grb'):
- 'dg_maps.layer.*'
- ~dg_maps.layer.agiv_grb
After the patch from #3099674 'agiv_grb' is no longer ignored but exported. This seems like a bug, should I open another issue for that?
2. I have a config file with ignores (some properties are ignored in myconfig.settings.yml), there is one translation for this config in Dutch (/translations/nl/myconfig.settings.yml) but none for German (/translations/de). The default behavior seems to have been changed by #3099674: /translations/de/myconfig.settings.yml is now also exported. I think this is a bug but I'm not sure what should be the expected behaviour here?
Comment #5
mpp CreditAttribution: mpp at AmeXio for District09 commentedComment #6
mpp CreditAttribution: mpp at AmeXio for District09 commentedSorry for #4 & #5, indentation was wrong for my project. (off-topic rant: I wish I could do this on github/gitlab instead of the patch files :s)
Comment #7
claudiu.cristea@mppm, it was only to change the vars. I've already fixed other bug, possible the one you mentioned in #4 and I've extended the test coverage for both bugs. Posting also a "test only" patch.
Comment #9
claudiu.cristeaFixing tests.
Comment #11
claudiu.cristeaThe tests are passing locally,
Comment #13
bircherThanks for the issue and the patch!
I had overlooked the possibility that things can return null, it happened already so many times I wish there was stricter typing like in rust.