Ignoring any config entities with an empty config sync directory causes PHP error

Created on 20 March 2024, 3 months ago
Updated 28 April 2024, 2 months ago

Problem/Motivation

Trying to access the main core configuration synchronization UI (at /admin/config/development/configuration) without having anything exported in the config sync directory triggers the PHP error described in 🐛 Configuration synchronization page errors out when config/sync is empty Needs work when the value for config_ignore.settings ignored_config_entities is not empty in the site's active configuration.

TypeError: Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge(): Argument #1 ($extensions) must be of type array, bool given, called in /var/lib/tugboat/stm/web/core/modules/field/field.module on line 323 in Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge() (line 111 of core/modules/field/src/ConfigImporterFieldPurger.php).
field_form_config_admin_import_form_alter(Array, Object, 'config_admin_import_form') (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'config_admin_import_form') (Line: 841)
Drupal\Core\Form\FormBuilder->prepareForm('config_admin_import_form', Array, Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

This is the same issue described in a closed issue for 8.x-2.x: 🐛 TypeError: Argument 1 passed to Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge() must be of the type array, bool given Closed: outdated . I've confirmed this issue still exists in the latest version (8.x-3.2) however.

Steps to reproduce

  1. Install the latest Drupal release (currently 10.2.4)
  2. Ensure the core field module is installed
  3. Ensure nothing has been exported to the config sync directory
  4. Install the latest version of the Config Ignore module (current 8.x-3.2)
  5. Navigate to the Config Ignore configuration form (/admin/config/development/configuration/ignore)
  6. Add a value to the "Configuration entity names to ignore" form element, Save configuration
  7. Navigate to the core Configuration Sychronization UI (/admin/config/development/configuration))
  8. See error.

Proposed resolution

Figure out what code in Config Ignore is causing the PHP error to be triggered when config_ignore.settings ignored_config_entities is not empty and no config has been exported to the config sync directory.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States joegraduate Arizona, USA

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

Merge Requests

Comments & Activities

  • Issue created by @joegraduate
  • 🇺🇸United States joegraduate Arizona, USA
  • 🇺🇸United States joegraduate Arizona, USA
  • 🇺🇸United States joegraduate Arizona, USA
  • First commit to issue fork.
  • Pipeline finished with Failed
    3 months ago
    Total: 205s
    #128712
  • 🇮🇳India sakthi_dev

    As if there is no config files in config sync then it is not required to validate the config ignore on Import. Please review.

  • Status changed to Needs review 3 months ago
  • 🇺🇸United States joegraduate Arizona, USA

    Added a test (ConfigIgnoreTest::testSynchronizeForm()) and also applied the fix for ConfigIgnoreTest::testSettingsForm() from 📌 Fix test failures on GitLab CI Needs review .

  • Pipeline finished with Failed
    3 months ago
    Total: 272s
    #129997
  • Pipeline finished with Success
    3 months ago
    Total: 453s
    #130012
  • Pipeline finished with Success
    3 months ago
    Total: 394s
    #130021
  • Pipeline finished with Success
    3 months ago
    Total: 205s
    #130033
  • Pipeline finished with Success
    3 months ago
    Total: 392s
    #130718
  • Pipeline finished with Success
    3 months ago
    Total: 240s
    #130763
  • 🇺🇸United States joegraduate Arizona, USA

    Merge requeset !25 should be ready for serious review now. I added a new test that demonstrates the issue without the other changes in the MR (see the failed tests-only pipeline result on GitLab CI).

    I was unable to get that test to fail until I added a step to install the core field module so I've also updated the issues summary to indicate that this issue only occurs when the core field module is installed.

  • Status changed to Needs work 3 months ago
  • 🇨🇭Switzerland bircher 🇨🇿

    I see, maybe there is some special logic to check if the whole storage is empty and then not do any further checks and so on an empty storage we should not add stuff that gets ignored.

    Fantastic work on the MR!
    But instead of checking the sync storage we should check the transformation storage and make sure it is in the default collection. I don't see why we would need to know what is in the sync storage at that point.

  • Pipeline finished with Canceled
    3 months ago
    #131016
  • Pipeline finished with Canceled
    3 months ago
    Total: 309s
    #131019
  • Pipeline finished with Canceled
    3 months ago
    Total: 83s
    #131020
  • Pipeline finished with Success
    3 months ago
    Total: 372s
    #131021
  • Pipeline finished with Success
    3 months ago
    Total: 287s
    #131028
  • Status changed to Needs review 3 months ago
  • 🇺🇸United States joegraduate Arizona, USA

    Thanks @bircher!

    I've tried to implement your suggestions in the MR. This should be ready for review again.

  • 🇺🇸United States joegraduate Arizona, USA

    Uploading static patch of current MR changes for use with composer.

  • 🇮🇳India sakthi_dev

    Thank you Bircher for commiting!

  • Status changed to Fixed 2 months ago
  • 🇨🇭Switzerland bircher 🇨🇿

    I moved the return statement so that we don't have to check for the default collection. And I removed the check for the direction because exporting will never have it empty unless some other event subsciber empties it and in that case I guess it would be better also to leave it empty.

    Thanks for the contribution!

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

Production build 0.69.0 2024