diff --git a/.tugboat/config.yml b/.tugboat/config.yml index dc87a25d4e..b1b5f43a99 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=../vendor/symfony/dependency-injection/Loader/schema/services.schema.json services: # What to call the service hosting the site. php: @@ -100,7 +101,7 @@ services: - PATH=${TUGBOAT_ROOT}/vendor/bin:$PATH ${TUGBOAT_ROOT}/scripts/ma-import-backup /tmp/database.sql.gz - rm -f /tmp/database.sql.gz # Set release for env indicator module - - drush sset environment_indicator.current_release ${TUGBOAT_GITHUB_HEAD} || true + - ${TUGBOAT_ROOT}/vendor/bin/drush sset environment_indicator.current_release ${TUGBOAT_GITHUB_HEAD} || true # Set file permissions such that Drupal will not complain. - chgrp -R www-data "${DOCROOT}/sites/default/files" - find "${DOCROOT}/sites/default/files" -type d -exec chmod 2775 {} \; @@ -118,6 +119,8 @@ services: - composer install --no-interaction --optimize-autoloader --no-cache - yarn install - PATH=${TUGBOAT_ROOT}/vendor/bin:$PATH ${TUGBOAT_ROOT}/scripts/ma-refresh-local --skip-db-prep + # Set release for env indicator module (also in update step, but build runs alone for PR previews from base). + - ${TUGBOAT_ROOT}/vendor/bin/drush sset environment_indicator.current_release ${TUGBOAT_GITHUB_HEAD} || true # This 'mysql' key acts as the hostname to access the service by from the php service. mysql: diff --git a/changelogs/DP-46272.yml b/changelogs/DP-46272.yml new file mode 100644 index 0000000000..80d1bf14e5 --- /dev/null +++ b/changelogs/DP-46272.yml @@ -0,0 +1,3 @@ +Fixed: + - description: Fix missing tag number in environment indicator after D11 upgrade. + issue: DP-46272 diff --git a/composer.json b/composer.json index 068ba3f646..308e3ea3b8 100644 --- a/composer.json +++ b/composer.json @@ -541,6 +541,9 @@ }, "drupal/editoria11y": { "Fix result name options to use editoria11y_results table instead of editoria11y_dismissals (DP-42700)": "patches/editoria11y--result-name-options-results.patch" + }, + "drupal/environment_indicator": { + "Fix getVersionIdentifier() to return NULL instead of empty string (https://www.drupal.org/project/environment_indicator/issues/3535382)": "patches/environment_indicator_getVersionIdentifier_return_null_3535382.patch" } }, "composer-exit-on-patch-failure": true, diff --git a/composer.lock b/composer.lock index ed96f99206..12ddb30da9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a6d89ea2953b3ffae673bc55fc09ebb3", + "content-hash": "1f4ed688d02b82a8256a0bc070a63651", "packages": [ { "name": "akamai-open/edgegrid-auth", diff --git a/conf/drupal/config/environment_indicator.settings.yml b/conf/drupal/config/environment_indicator.settings.yml index e3bb7d552d..902b1ebfe7 100644 --- a/conf/drupal/config/environment_indicator.settings.yml +++ b/conf/drupal/config/environment_indicator.settings.yml @@ -2,5 +2,5 @@ _core: default_config_hash: Bi0EyyiH6m5wpHRfxlKhqTIhAZayhRQudheDzAcrotU toolbar_integration: { } favicon: true -version_identifier: environment_indicator_current_release -version_identifier_fallback: deployment_identifier +version_identifier: deployment_identifier +version_identifier_fallback: environment_indicator_current_release diff --git a/patches/environment_indicator_getVersionIdentifier_return_null_3535382.patch b/patches/environment_indicator_getVersionIdentifier_return_null_3535382.patch new file mode 100644 index 0000000000..3eaca62128 --- /dev/null +++ b/patches/environment_indicator_getVersionIdentifier_return_null_3535382.patch @@ -0,0 +1,144 @@ +diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt +index 639dfec4bb0025d6e84d5e6b48409708ad966da1..7f6585956d4a6d89aabc180816d304332e9ec7c7 100644 +--- a/.cspell-project-words.txt ++++ b/.cspell-project-words.txt +@@ -3,3 +3,4 @@ tinycon + mrfelton + isholgueras + trackleft2 ++colour +\ No newline at end of file +diff --git a/src/Service/EnvironmentIndicator.php b/src/Service/EnvironmentIndicator.php +index cef2f0bb5a3e0a40f57af71c4017075dbd8065a8..d94d45a1599d8d8d173e357ff7832cab20728f44 100644 +--- a/src/Service/EnvironmentIndicator.php ++++ b/src/Service/EnvironmentIndicator.php +@@ -154,10 +154,10 @@ class EnvironmentIndicator { + protected function getVersionIdentifier(string $type): ?string { + switch ($type) { + case 'environment_indicator_current_release': +- return (string) $this->state->get('environment_indicator.current_release'); ++ return !empty($this->state->get('environment_indicator.current_release')) ? (string) $this->state->get('environment_indicator.current_release') : NULL; + + case 'deployment_identifier': +- return (string) $this->settings->get('deployment_identifier'); ++ return !empty($this->settings->get('deployment_identifier')) ? (string) $this->settings->get('deployment_identifier') : NULL; + + case 'drupal_version': + return \Drupal::VERSION; +diff --git a/tests/src/Functional/EnvironmentIndicatorServiceTest.php b/tests/src/Functional/EnvironmentIndicatorServiceTest.php +new file mode 100644 +index 0000000000000000000000000000000000000000..7f548bda215a50e19ca01befae740b66d6e47c0a +--- /dev/null ++++ b/tests/src/Functional/EnvironmentIndicatorServiceTest.php +@@ -0,0 +1,111 @@ ++environmentIndicatorService = $this->container->get('environment_indicator.indicator'); ++ } ++ ++ /** ++ * Tests that empty state values are handled correctly. ++ * ++ * This test validates the behavior of getVersionIdentifier when ++ * environment_indicator.current_release is set to an empty string. ++ */ ++ public function testEmptyStateValue(): void { ++ // Set empty string in state. ++ \Drupal::state()->set('environment_indicator.current_release', ''); ++ // Create a user with permission. ++ $user = $this->drupalCreateUser(['view environment indicator current release']); ++ $this->drupalLogin($user); ++ $result = $this->environmentIndicatorService->getCurrentRelease(); ++ // This assertion will FAIL with current implementation (returns '') ++ // and PASS after applying the fix (returns NULL) ++ $this->assertNull($result, 'Empty state value should return NULL, not empty string'); ++ } ++ ++ /** ++ * Tests that zero values are handled correctly. ++ * ++ * This test validates the behavior when state contains integer 0. ++ */ ++ public function testZeroStateValue(): void { ++ // Set integer 0 in state. ++ \Drupal::state()->set('environment_indicator.current_release', 0); ++ // Create a user with permission. ++ $user = $this->drupalCreateUser(['view environment indicator current release']); ++ $this->drupalLogin($user); ++ $result = $this->environmentIndicatorService->getCurrentRelease(); ++ $this->assertNull($result, 'Zero value should be treated as empty and return NULL'); ++ } ++ ++ /** ++ * Tests permission handling. ++ */ ++ public function testPermissionHandling(): void { ++ // Set a value in state. ++ \Drupal::state()->set('environment_indicator.current_release', 'v1.0.0'); ++ // Create a user WITHOUT the required permission. ++ $user = $this->drupalCreateUser([]); ++ $this->drupalLogin($user); ++ $result = $this->environmentIndicatorService->getCurrentRelease(); ++ $this->assertNull($result, 'Should return NULL when user lacks permission'); ++ } ++ ++ /** ++ * Tests deployment_identifier with empty value. ++ * ++ * This test validates that empty deployment_identifier returns NULL. ++ */ ++ public function testEmptyDeploymentIdentifier(): void { ++ // Configure to use deployment_identifier as primary. ++ $this->config('environment_indicator.settings') ++ ->set('version_identifier', 'deployment_identifier') ++ ->set('version_identifier_fallback', 'drupal_version') ++ ->save(); ++ // Create a user with permission. ++ $user = $this->drupalCreateUser(['view environment indicator current release']); ++ $this->drupalLogin($user); ++ $result = $this->environmentIndicatorService->getCurrentRelease(); ++ // Since deployment_identifier will be empty in test environment, ++ // this should fall back to drupal_version and return that. ++ $this->assertIsString($result, 'Should fall back to drupal_version when deployment_identifier is empty'); ++ $this->assertNotEmpty($result, 'Drupal version should not be empty'); ++ } ++ ++}