From 563e9a68123f839e55ff547e6cbaea93d311197c Mon Sep 17 00:00:00 2001 From: Lee Rowlands Date: Mon, 20 May 2024 09:37:47 +1000 Subject: [PATCH] Issue #3385934 by phthlaap, joegraduate, useernamee, alexpott: The configuration synchronization page encounters errors when core.extension.yml is missing in the config/sync directory (cherry picked from commit 96a211c7b0a21763599373049c66eb2106d16888) --- core/modules/field/field.module | 6 +++--- .../FieldImportDeleteUninstallUiTest.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/modules/field/field.module b/core/modules/field/field.module index c5428e53b5f..b366eb8bc02 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -314,11 +314,11 @@ function field_config_import_steps_alter(&$sync_steps, ConfigImporter $config_im * @see \Drupal\field\ConfigImporterFieldPurger */ function field_form_config_admin_import_form_alter(&$form, FormStateInterface $form_state) { - // Only display the message when there is a storage comparer available and the - // form is not submitted. + // Only display the message when core.extension is available in the source + // storage and the form is not submitted. $user_input = $form_state->getUserInput(); $storage_comparer = $form_state->get('storage_comparer'); - if ($storage_comparer && empty($user_input)) { + if ($storage_comparer?->getSourceStorage()->exists('core.extension') && empty($user_input)) { $field_storages = ConfigImporterFieldPurger::getFieldStoragesToPurge( $storage_comparer->getSourceStorage()->read('core.extension'), $storage_comparer->getChangelist('delete') diff --git a/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php b/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php index fc927c478b0..ed065630965 100644 --- a/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/tests/src/Functional/FieldImportDeleteUninstallUiTest.php @@ -130,4 +130,18 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase { $this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Text field has been completed removed from the system.'); } + /** + * Tests if the synchronization form is available when the core.extension.yml is missing. + */ + public function testSynchronizeForm(): void { + $sync = $this->container->get('config.storage.sync'); + $this->copyConfig($this->container->get('config.storage'), $sync); + + $sync->delete('core.extension'); + $this->drupalGet('admin/config/development/configuration'); + $assertSession = $this->assertSession(); + $this->assertSession()->elementExists('css', 'input[value="Import all"]')->click(); + $assertSession->pageTextContains('The core.extension configuration does not exist.'); + } + }