When upgrading from 4.0.17 to 4.0.21 on a Drupal 9 with PHP 7.4, the following error occurs :

ParseError: syntax error, unexpected ')', expecting variable (T_VARIABLE) in Composer\Autoload\{closure}() (line 96 of modules/contrib/environment_indicator/src/ToolbarHandler.php).

If PHP < 8.0 is not supported anymore :

  • it should be reflected in the composer.json
  • it shoud at least be a minor version and not a bug fix version
Command icon 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

oldeb created an issue. See original summary.

liam morland’s picture

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

trackleft2’s picture

Title: PHP version compatibility » Add back PHP 7.4 version compatibility
Status: Active » Needs review
Related issues: +#3483897: [META] Release Plan for Environment Indicator Patch Release 4.0.22

My merge requests adds back support for PHP 7.4

It looks like the issue was caused by the trailing comma on this line:
https://git.drupalcode.org/project/environment_indicator/-/merge_request...
This syntax is valid in newer PHP versions, but breaks on PHP 7.4, which the module currently supports.

To help catch similar issues, I’ve added a PHPUnit test to lint PHP files across supported versions:
https://git.drupalcode.org/project/environment_indicator/-/merge_request...

While this won’t catch the trailing comma specifically (as PHP 7.4 is no longer available in the GitLab runner environment), it sets us up for stricter compatibility checks going forward. I’d recommend holding off on using syntax that requires PHP 8.0+ until the module drops support for older versions in a future minor release.

I am also adding this issue to the #3483897: [META] Release Plan for Environment Indicator Patch Release 4.0.22

liam morland’s picture

Version: 4.0.21 » 4.x-dev

If changes like this are going to be made, it makes it very urgent to get a branch which is aimed at currently-supported versions of Drupal. This change introduces a coding standards error. Contributing to this module will become more difficult because people will need to remember to write in an old version of PHP, remembering what changes have been made and what coding standard issues to ignore.

trackleft2’s picture

I agree that maintaining compatibility with PHP 7.4 makes contributions trickier, and there’s value in targeting modern environments. That said, this patch is specifically scoped to fix a regression introduced in a patch release (4.0.18–4.0.21) that broke sites still running PHP 7.4 — without any documented change in requirements.

To avoid repeating that mistake, I’d suggest the following sequence:

  1. Merge this fix to restore compatibility in 4.x and ensure sites on PHP 7.4 can safely upgrade within the same major version.
  2. Create a final 4.0.x release that:
    • Maintains support for Drupal 9.3 through 11.
    • Avoids changes that break backward compatibility for supported environments.
  3. After that, address the syntax issue in #3483903: Drop support for versions of Drupal older than 10.3, which also drops support for Drupal core versions earlier than 10.3.
  4. Then create a 4.1.0-beta1 minor release

We’d appreciate review on any of the “Needs review” issues blocking the final 4.0.x release:
#3483897: [META] Release Plan for Environment Indicator Patch Release 4.0.22 or #3468997: [META] Release Plan for Environment Indicator Minor (feature) Release 4.1.0

liam morland’s picture

I think it would be reasonable to fix just the regression and then move on to 4.1.x.

trackleft2’s picture

I've updated the PHPUnit tests so that they pass in all of the gitlab-ci jobs.

While updating the PHPUnit Test I was testing the module using the combination of PHP 8.3 and Drupal Core 11.0.13 as well.

trackleft2’s picture

Also, it appears that all of the gitlab-ci tests are currently passing due to this issue: #3526179: Validate stage may use outdated artifact, leading to flaky test results

trackleft2’s picture

  • trackleft2 committed 075d6445 on 4.x
    Issue #3519033 by trackleft2, liam morland, oldeb: Add back PHP 7.3 and...
trackleft2’s picture

Title: Add back PHP 7.4 version compatibility » Add back PHP 7.3 and Drupal 9.3 version compatibility
liam morland’s picture

You could create a hotfix release based on 4.0.21 which just has the fix for this regression and then continue development of 4.x with a minimum of Drupal 10.3 in preparation for a 4.1.0 release.

trackleft2’s picture

Sorry for taking so long in creating a release with this in it. We have a lot tied up in our release number at the moment and don't want to back track since our next patch release should drop any day now and it would be a lot of administrative work to sneak in a hotfix.

On the bright side, during the process of creating the new release, we did realize that we should be supporting 7.3 and Drupal 9.3 and changed that to our target.

trackleft2’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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