Problem/Motivation
Since version 4.0.11, the toolbar item includes a random string of characters in parentheses to the left of the environment name. This appears to be where the release state information would appear. We don't set this state in our site and the random string of characters never appeared before version 4.0.11.

Steps to reproduce
1. Update to 4.0.11.
2. Do not set or unset a environment_indicator.current_release version state.
Proposed resolution
A merge request has been submitted to address this issue: MR #44.
The proposed solution in the merge request makes several changes:
1. Introduces new configuration settings for `version_identifier` and `version_identifier_fallback` in `environment_indicator.settings.yml`.
2. Adds these settings to the schema and a new update hook to initialize them.
3. Updates the `ToolbarHandler` class to use these new settings and display the appropriate version identifier.
4. Updates the settings form to allow selecting the source of the version identifier and a fallback option.
For existing sites, the update hook `environment_indicator_update_8101` ensures backward compatibility by initializing the new settings with default values if they are not already set:
function environment_indicator_update_8101() {
$config_factory = \Drupal::configFactory();
$settings = $config_factory->getEditable('environment_indicator.settings');
if ($settings->get('version_identifier') === NULL) {
$settings->set('version_identifier', 'environment_indicator_current_release');
}
if ($settings->get('version_identifier_fallback') === NULL) {
$settings->set('version_identifier_fallback', 'deployment_identifier');
}
$settings->save();
}
When I set a release state with the recommended Drush command on the environment indicator settings screen, the random characters go away and the release version I set appears. (drush sset environment_indicator.current_release v1.2.44)
This confirms that the random string issue is due to the missing release state. The merge request will resolve this by ensuring the release state is only displayed when it is explicitly set.
How to test
1. Ensure the Environment Indicator UI module is enabled.
2. Update your site to the latest version including the merge request changes.
3. Navigate to the environment indicator settings page at `/admin/config/development/environment-indicator`.
4. Verify that the new settings for `version_identifier` and `version_identifier_fallback` are present.
5. Ensure the default values are set correctly for both settings.
6. Test by not setting the `environment_indicator.current_release` state and observe that no random string appears.
7. Set a release state using the command: drush sset environment_indicator.current_release v1.2.44 and verify that the release version appears correctly.
8. Change the `version_identifier` setting to different options (e.g., `deployment_identifier`, `drupal_version`, `none`) and verify the output in the toolbar.
9. Ensure the fallback option works by setting `version_identifier` to a non-existing source and checking if the fallback value is used.
For convenience, a Landofile is provided in the merge request body for those who want to use it.
Screenshots of the New UI



| Comment | File | Size | Author |
|---|---|---|---|
| #39 | 3324621-39.patch | 17.29 KB | joegraduate |
| #34 | Screenshot 2024-06-21 at 12.50.51 PM.png | 561.42 KB | trackleft2 |
| #34 | Screenshot 2024-06-21 at 12.51.08 PM.png | 81.86 KB | trackleft2 |
| #34 | Screenshot 2024-06-21 at 12.51.24 PM.png | 67.05 KB | trackleft2 |
| #20 | environment_indicator-replace-deploy-id-with-drupal-version-3324621-20.patch | 882 bytes | ericjenkins |
Issue fork environment_indicator-3324621
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ankitjhakal commentedComment #3
utcwebdev commentedI see this issue as well. Thanks for reporting, I was just about to report it myself.
Comment #4
ankitjhakal commentedHi All, I followed the steps. Required and installed the module. Cleared all cache, ran
drush sdel environment_indicator.current_releasecommand and testing after saving the setting form with toolbar and show favicon checkbox. Still i am not seeing any random string here. Can you elaborate little bit more when this one occurring or i have done something wrong with debugging.I am using D9.4.8 and php 8.1.
Module V4.0.11.
Comment #5
ankitjhakal commentedThis code is returning NULL in starting as there is no state var set for current_release and uncommented deployment_identifier line in settings.php file.
Comment #6
utcwebdev commented@ankitjhakal
What was apparently a random string is actually the text content of my project's deployment_identifier file (in my current docker container Lando appserver environment this is "G %9[+R=").
I'll do more research on this and how the file gets created in my local development environment.
It looks like a build artifact from Acquia BLT setup script commands.
Comment #7
utcwebdev commentedConfirmed: the deployment_identifier file is created as a random string during Acquia BLT setup during drupal:install, and during artifact generation during blt deploy, where it can be specified as a tag for the deploy release.
Looks like this is not a bug.
Comment #8
ankitjhakal commentedHi utcwebdev, so can you please move this issue in closed status.
Comment #9
darktek commented@utcwebdev It is in fact a bug, because the module should be taking the BLT commands in consideration, I'm having the same issue.
I created a patch to get rid of the identifier version in the title. Maybe we could have some kind of settings asking us if we want to have the version indentifier before the title, that could fix the issue in these cases
Comment #10
utcwebdev commented@DarkteK Thank you for the patch. I agree, an option to disable/enable the identifier would be helpful.
I think the module is behaving as designed, but not as expected, when used with the BLT workflow. Unless there is a tag specified during a deployment, BLT generates the random string as deployment_identifier. I still see a seemingly random string after CI/CD develop-build branch deployment to our hosted Acquia dev environment, though it looks suspiciously like a failed timestamp. Also, the favicon icon overlay text is borked.
Perhaps this is more of a BLT issue where the deployment identifier could be improved. The BLT developer justification for it to be a random string is because "Drupal uses the deployment identifier to seed the APCu cache", and generating a random string is the most efficient/fast method. The identifier helps to clear the Twig cache when theme updates are deployed, and class autoloader cache when a module is updated.
Comment #11
devkinetic commented+1 to making it optional, I guess that was an oversight when I initially added it.
Having the option is really nice when using, for example, tag based deployments where you use ENV to set the
deployment_identifierlike so in settings:It's useful when you are already using deployment identifier in a unique way, so you don't have to set the state as well on top of it. Not everyone is using deployment identifier (you should), or does but it doesn't provide anything meaningful in the case of BLT, so making it optional is nice.
While on the topic of deployment identifier, but somewhat off-topic, I am using the following in my settings.local.php to set it to the current branch, this works out really well!
Comment #12
kurttrowbridgeThanks for reporting this! Just chiming in to add that this also shows up on Pantheon, where the latest commit hash appears before the environment name when on the development environment, and the Pantheon deployment ID (e.g. "test_35") appears in test and live.
I personally agree with the suggestion of this being a configurable option that could be enabled or disabled. Even if not, I wonder about the possibility of moving it to display after the environment name, rather than before [e.g. Local (rbVZt`Z= )], which would prevent the favicon overlay from being affected.
Thanks!
Comment #13
dabblela commentedConfigurable would be nice but thankfully there is a straightforward code path to changing this behavior if you need to:
Comment #14
lisastreeter commentedAlso seeing the "random" string on a platform.sh site. Wasn't displayed on local environment but appeared once I deployed code to a platform.sh environment.
Comment #15
pcate commented+1 for this being configurable. It can be confusing to editors who don't know what the (seemingly) random string is.
Comment #16
devkinetic commentedUntil there is a patch, literally the easiest thing to do is set the state for the current release per the README. You can see in the code https://git.drupalcode.org/project/environment_indicator/-/blob/4.x/src/... that the deployment identifier is only used as a fallback.
Comment #17
joegraduateNeeds IS summary update for suggested new configuration setting. Affects all 4.x-dev (and all 4.x releases since 4.0.11).
Issue was introduced with the changes committed for #2610208: Move procedural functions to a manager due to the deployment identifier now being used (if available) as a fallback for current_release value that is prepended to the environment title when the current_release value is not set in the state.
Comment #18
joegraduateClosed #3325538: Remove extra strings added to the environment title after upgraded to 4.0.11 as duplicate of this issue. Credit should be included for the contributors to that issue when this fixed.
Comment #19
joegraduateComment #20
ericjenkins commentedWe have also been experiencing the random characters in parentheses prepended to the environment label. We also observed that the characters come from a
deployment_identifierfile located in our project's root directory.I'm submitting patch #20 which is similar to #9, but it keeps the
environment_indicator.current_releasestate variable check. It only replaces thedeployment_identifierfallback with a\Drupal::VERSIONfallback.Comment #21
pameeela commentedI was for disabling the fallback but I really like @ericjenkins' idea of showing the Drupal version. I think that would be useful info to highlight, whereas the deploy ID is really really not.
Comment #24
trackleft2Adding static patch for CI tools with all the changes in the merge request as of 17c96bd7b7b4d916f43bd30dd58806e21fc956bf against the 4.x branch.
Comment #25
trackleft2Comment #27
trackleft2I've added a merge request with the fallback option.
https://git.drupalcode.org/project/environment_indicator/-/merge_request...
You should be able to view a site with this merge request installed here: https://mr44-ujeql2avin1q2wcv5myxo47tlli6m5z1.tugboatqa.com/
username:admin
password: admin
Configuration page here: https://mr44-ujeql2avin1q2wcv5myxo47tlli6m5z1.tugboatqa.com/admin/config...
Comment #29
trackleft2Adding static patch of https://git.drupalcode.org/project/environment_indicator/-/merge_request...
Comment #30
trackleft2Suggestion: when the none option is selected for the Source of version identifier to display field, a fall back option should not be allowed.
Comment #31
trackleft2I've updated the merge request to disallow setting a fallback if a primary version indicator source is set to none.
Comment #32
trackleft2Comment #33
trackleft2Comment #34
trackleft2Comment #35
trackleft2Comment #36
trackleft2Comment #38
joegraduateThe changes in @trackleft2's MR work great for me in my testing. I really like that it adds additional configuration options for what is used as the version indicator and the fallback.
Comment #39
joegraduateUploading static patch with latest changes from MR (usable with 4.0.19).
Comment #42
isholgueras commentedExcelent work. I'll release it in the 4.0.20 version.
Comment #43
isholgueras commented