Fix PHP Fatal error: Type of GoogleAnalyticsArgument::$operator must be string with Drupal ~10 and PHP 8.1

Created on 23 January 2023, almost 2 years ago

Problem/Motivation

Facing the following error

[Mon Jan 23 12:09:26.579252 2023] [php:error] [pid 4233] [client 10.50.111.41:33170] PHP Fatal error:  Type of Drupal\\google_analytics_reports\\Plugin\\views\\argument\\GoogleAnalyticsArgument::$operator must be string (as in class Drupal\\views\\Plugin\\views\\argument\\ArgumentPluginBase) in /var/www/html/sandboxes/drupal10google_analytics_reports_3__test/web/modules/contrib/google_analytics_reports/src/Plugin/views/argument/GoogleAnalyticsArgument.php on line 19

Steps to reproduce

Build Drupal ~10.0 sandbox test site and have Drush ~11.0

composer create-project drupal/recommended-project:~10.0 /var/www/html/sandboxes/drupal10google_analytics_reports_3__test
cd /var/www/html/sandboxes/drupal10google_analytics_reports_3__test/
composer require drush/drush:~11.0;

Change minimum stability to dev for testing on the recommended Drupal 9 project template

composer config minimum-stability dev

Add the Google Analytics Reports module

composer require drupal/google_analytics_reports:3.x-dev;

Change file/directory mod and ownership of files:

cd /var/www/html/sandboxes/drupal10google_analytics_reports_3__test/
sudo chmod 775 -R .;sudo chown www-data:$USER -R .;

Install with Drush

./vendor/drush/drush/drush site:install standard --yes --site-name="Google Analytics Reports 3.x-dev - Real physical testing with Drupal ~10" --account-name="webmaster" --account-pass="d" --account-mail="test@drupal.org" --db-url="mysql://root:123___@localhost/sandboxes_drupal10google_analytics_reports_3__test" -vvv ;

./vendor/drush/drush/drush pm:enable google_analytics_reports
The following module(s) will be enabled: google_analytics_reports, google_analytics_reports_api

 Do you want to continue? (yes/no) [yes]:
 > 

>  [notice] Message: Imported 510 Google Analytics fields.
> 
 [success] Successfully enabled: google_analytics_reports, google_analytics_reports_api

Rebuild the cache:

sudo chmod 775 -R .;sudo chown www-data:$USER -R .;
./vendor/drush/drush/drush cache:rebuild

Open a browser and change the address to:
http://localhost/sandboxes/drupal10google_analytics_reports_3__test/web/

Then the following fatal error will show
PHP Fatal error: Type of Drupal\\google_analytics_reports\\Plugin\\views\\argument\\GoogleAnalyticsArgument::$operator must be string

Proposed resolution

  • Fix PHP 8.1 issues
  • Fix Drupal ~10 issues

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ✅ Code review by maintainers
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Release notes snippet
  • v Release google_analytics_reports-8.x-3.0 , google_analytics_reports-4.0.0-alpha2

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • Issue #3335698 by Rajab Natshah : Fixed PHP Fatal error: Type of GoogleAnalyticsArgument::$operator must be string with Drupal ~10 and PHP 8.1
🐛 Bug report
Status

Fixed

Version

3.0

Component

All modules

Created by

🇯🇴Jordan Rajab Natshah Jordan

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024