Problem/Motivation

after updating Drupal from 9.5.5 to 9.5.8 I received WSOD and after enabling error verbose I see this critical error:

syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE) web/modules/contrib/google_tag/src/EventSubscriber/ResponseSubscriber.php:29

Steps to reproduce

install and enable the module, update Drupal to 9.5.8

Issue fork google_tag-3356646

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

almador created an issue. See original summary.

almador’s picture

Maybe this is related to php version?
I'm on Pantheon and it is set to 7.4

abarrio’s picture

Hi all.
the problem here is that on class ResponseSubscriber the code is using a functionality wich has been introduced on php 8.0.
You can see it here: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion

So I think a restriction should be added on composer to be installed on php 8.0+ platforms.

abarrio’s picture

Status: Active » Needs work
unqunq’s picture

I'm getting the same error and I am on PHP 7.4. I tried upgrading but my site still uses some dependencies which are not ready for PHP 8+ making this impossible to use.

If anyone wants to get this working on PHP 7.4 then here is an article about the property promotion in PHP 8. https://stitcher.io/blog/constructor-promotion-in-php-8

I haven't tested the actual functionality of the module past fixing this file so there could be a lot more PHP 8 related parts that need downgraded in order to make this work with PHP 7.4

So I guess we just need to follow @abarrio's suggestion.

Edit:
I installed a lower version of this module and I got no errors: composer require 'drupal/google_tag:^1.6'

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

japerry’s picture

Status: Needs work » Active

Can confirm. Module supports D9 and 7.4 via composer, but has PHP8+ syntax. An upcoming patch is going to remove PHP8+ syntax. In the meantime, I added PHP 7.4 testing, which should fail here.

  • japerry committed 2c762c52 on 2.0.x
    Issue #3356646 by japerry: syntax error, unexpected 'private' (T_PRIVATE...
japerry’s picture

Status: Active » Fixed
pianomansam’s picture

Can we get a release with this fix included?

tim corkerton’s picture

I am on PHP7.4 Obviously I'd like the latest version but I am encountering this issue.
What is the recommended approach given that upgrading to PHP8 is not an option right now?

japerry’s picture

Yup, there should be a release by next tuesday (May 23). It wasn't our intention to drop support for PHP 7.4, so you can get the fix by updating to head or waiting until Tuesday for the full release.

tim corkerton’s picture

Thank you. I can confirm this works well with PHP7.4

Status: Fixed » Closed (fixed)

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