The configuration synchronization page encounters errors when core.extension.yml is missing in the config/sync directory.

Created on 7 September 2023, about 1 year ago
Updated 3 June 2024, 5 months ago

Problem/Motivation

Configuration synchronization page is broken due to error.

Steps to reproduce

Remove the file core.extension.yml in config/sync directory.

Visit syncronise tab at: /admin/config/development/configuration

Get the below error:

TypeError: Argument 1 passed to Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge() must be of the type array, bool given, called in /modules/field/field.module on line 323 in Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge() (line 111 of core/modules/field/src/ConfigImporterFieldPurger.php).

Proposed resolution

Improve handling of empty config/sync in the field module in hook field_form_config_admin_import_form_alter.

🐛 Bug report
Status

Fixed

Version

10.3

Component
Field 

Last updated about 4 hours ago

Created by

🇸🇮Slovenia useernamee Ljubljana

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • Issue created by @useernamee
  • Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Not currently mergeable.
  • @useernamee opened merge request.
  • last update about 1 year ago
    Custom Commands Failed
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States joegraduate Arizona, USA

    joegraduate changed the visibility of the branch 3385934-configuration-synchronization-page to hidden.

  • 🇺🇸United States joegraduate Arizona, USA

    joegraduate changed the visibility of the branch 3385934-configuration-synchronization-page to active.

  • 🇺🇸United States joegraduate Arizona, USA

    Looks like the target branch for the MR needs to be updated to to 11.x

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

    I cherry-picked @useernamee's commit into a new branch based on 11.x and created a new MR targeting 11.x

  • Status changed to Needs work 8 months ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

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

    Thanks for working on this issue.

    Will need a failing test case to show the issue.

  • First commit to issue fork.
  • Pipeline finished with Failed
    8 months ago
    Total: 533s
    #125039
  • Pipeline finished with Success
    8 months ago
    Total: 494s
    #128694
  • 🇻🇳Vietnam phthlaap

    phthlaap changed the visibility of the branch 3385934-configuration-synchronization-page to hidden.

  • Status changed to Needs review 8 months ago
  • Pipeline finished with Success
    8 months ago
    Total: 4530s
    #128829
  • 🇺🇸United States joegraduate Arizona, USA

    This GitLab "Test-only changes" pipeline in MR !7103 fails as expected as of @phthlaap's latest changes:

    PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
    Testing Drupal\Tests\field\Functional\FieldImportDeleteUninstallUiTest
    .
    E                                                                  2 / 2 (100%)
    Time: 00:16.901, Memory: 4.00 MB
    There was 1 error:
    1) Drupal\Tests\field\Functional\FieldImportDeleteUninstallUiTest::testSynchronizeForm
    Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.
    /builds/issue/drupal-3385934/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-3385934/vendor/behat/mink/src/WebAssert.php:145
    /builds/issue/drupal-3385934/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php:143
    /builds/issue/drupal-3385934/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
    ERRORS!
    Tests: 2, Assertions: 28, Errors: 1.
    
  • 🇺🇸United States joegraduate Arizona, USA
  • Pipeline finished with Success
    8 months ago
    Total: 960s
    #129621
  • Status changed to Needs work 8 months ago
  • 🇺🇸United States smustgrave

    So I tried to replicate locally by emptying my config/sync folder and going to /admin/config/development/configuration but I don't get any error or see anything in the logs.

    Could additional steps be added to the issue summary.

  • Status changed to Needs review 8 months ago
  • 🇻🇳Vietnam phthlaap

    @smustgrave just remove the file core.extension.yml instead of all .yml files

  • 🇺🇸United States smustgrave

    Title and issue summary should be updated to reflect the issue.

  • Status changed to RTBC 7 months ago
  • 🇺🇸United States smustgrave

    Title and issue summary have both been updated.

    Seems like an edge case but definitely do see the issue, tests also show it

    1) Drupal\Tests\field\Functional\FieldImportDeleteUninstallUiTest::testSynchronizeForm
    Behat\Mink\Exception\ExpectationException: Current response status code is 500, but 200 expected.
    /builds/issue/drupal-3385934/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-3385934/vendor/behat/mink/src/WebAssert.php:145
    /builds/issue/drupal-3385934/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php:143
    /builds/issue/drupal-3385934/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
    ERRORS!
    Tests: 2, Assertions: 28, Errors: 1.
    

    Tried to see if there is a better spot to put this test but anywhere else felt like a stretch for any other test function.

    Think this should be good.

  • Status changed to Needs work 7 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    I feel this fix is in the wrong place. If core.extension is missing we should have bailed way before hitting hook_config_import_steps_alter.

    Given the importance of core.extension I think we can add something to \Drupal\system\SystemConfigSubscriber::onConfigImporterValidateNotEmpty like

        if (!isset($importList['core.extension')) {
          $event->getConfigImporter()->logError($this->t('This import does not contain core.extension configuration, so has been rejected.'));
        }
    

    Eventually schema validation is going to do this for us.

  • 🇮🇳India pradhumanjainOSL

    pradhumanjain2311 made their first commit to this issue’s fork.

  • Pipeline finished with Failed
    7 months ago
    Total: 553s
    #146289
  • Pipeline finished with Failed
    7 months ago
    Total: 573s
    #146353
  • 🇻🇳Vietnam phthlaap

    #27 It will impact the import configuration form when there are no changes in the core extension.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Ahh interesting... must have forgotten something along the way... posted a formulation on the MR that will work...

  • 🇮🇳India keshav patel

    Keshav Patel made their first commit to this issue’s fork.

  • Pipeline finished with Failed
    7 months ago
    Total: 614s
    #146439
  • 🇻🇳Vietnam phthlaap

    @alexpott the core.extension configuration is validated in core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php:93. I think we no need to validate again.

        $config_importer = $event->getConfigImporter();
        if ($config_importer->getStorageComparer()->getSourceStorage()->exists('core.extension')) {
          $this->validateModules($config_importer);
          $this->validateThemes($config_importer);
          $this->validateDependencies($config_importer);
        }
        else {
          $config_importer->logError($this->t('The core.extension configuration does not exist.'));
        }

    It also have test cases to cover: core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php::testMissingCoreExtension

    But even when it is validated I think we also need fix the core/modules/field/field.module:324 to prevent the TypeError message when access the page /admin/config/development/configuration

  • Status changed to Needs review 7 months ago
  • Pipeline finished with Success
    7 months ago
    Total: 1186s
    #146560
  • Status changed to RTBC 6 months ago
  • 🇺🇸United States smustgrave

    Re-ran test-only feature https://git.drupalcode.org/issue/drupal-3385934/-/jobs/1326634 which shows the test is still covering the change.

    Believe the feedback from @alexpott has been addressed

    I did save credit for the users who have worked on the issue, did not include just applying a suggestion.

  • Pipeline finished with Success
    6 months ago
    Total: 576s
    #166507
  • Pipeline finished with Success
    6 months ago
    Total: 666s
    #166565
    • larowlan committed 54096101 on 10.3.x
      Issue #3385934 by phthlaap, joegraduate, useernamee, alexpott: The...
    • larowlan committed 563e9a68 on 10.4.x
      Issue #3385934 by phthlaap, joegraduate, useernamee, alexpott: The...
    • larowlan committed 3a3973ed on 11.0.x
      Issue #3385934 by phthlaap, joegraduate, useernamee, alexpott: The...
    • larowlan committed 96a211c7 on 11.x
      Issue #3385934 by phthlaap, joegraduate, useernamee, alexpott: The...
  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

    Committed to 11.x and backported to 11.0.x, 10.4.x and 10.3.x

  • Status changed to Fixed 6 months ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024