Google Analytics Counter module resulting in cron run failure on Drupal 10

Created on 15 September 2023, 9 months ago
Updated 25 September 2023, 9 months ago


The plan is to use the google analytics counter module to show the view count of some belonging to a certain content type.
So i followed the documentation that is being provided ( )
Now after following the steps and doing the necessary configurations when i am running cron i am getting this error

Warning: Trying to access array offset on value of type null in Drupal\Core\Cron->processQueue() (line 264 of core/lib/Drupal/Core/Cron.php).

So i checked out the code and what i figured out is when the cron is run, and the worker is google analytics counter the pluginid,plugindefintion, and the configuration is not getting passed and hence $lease_time = $worker->getPluginDefinition()['cron']['time']; this is receiving null value, and the cron run is stopped abruptly and it's throwing error/warning mentioned above.

Steps to reproduce

1. Download and enable the module google analytics counter
2. Implement the necessary configurations ( )
3. Run Cron

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report






Created by

🇮🇳India sandipta

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates some issue and comment data are missing.

  • 🇩🇪Germany simonbaese Berlin

    I saw your thread on reddit and took a quick look at this issue. The problem is that the plugin GoogleAnalyticsCounterQueueBase is not "constructed" correctly. It extends the QueueWorkerBase, but also overwrites the constructor (without calling the parent constructor) and create methods. In the comment, it said that dependency injection is not required, although services are used in the plugin and the ContainerFactoryPluginInterface is also used. This should be reworked in another issue.

    For now I can only provide a simple patch, because I am traveling. Also, I was not able to do extensive testing, so please let me know if it works.

  • 🇮🇳India sandipta

    Sure. I will test it out and will let you know. Thanks for the help 🙂

  • Open in Jenkins → Open on →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    8 pass
  • Open in Jenkins → Open on →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    8 pass
  • 🇮🇳India Vivek Panicker Kolkata

    Nice spot there @simonbaese.

    I got inspiration from your idea to create this patch.

    @sandipta please review this patch since it is not tested and see if it helps resolve your issue.

  • Open in Jenkins → Open on →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    8 pass
  • 🇮🇳India sandipta

    Definitely, I'll test it out and will let you know. Thanks for the patch. @Vivek Panicker

  • 🇩🇪Germany simonbaese Berlin

    @Vivek Panicker The __construct() and create() call in GoogleAnalyticsCounterQueueBase is not necessary since it extends the QueueWorkerBase which extends the PluginBase.

    The PluginBase constructor does everything needed to instantiate the plugin for the moment.

    Since no dependency injection is used at the moment the `create()` method required by the ContainerFactoryPluginInterface is not necessary (should change in the context of another issue as mentioned above).

  • Status changed to Fixed 9 months ago
  • 🇸🇰Slovakia kaszarobert

    I committed patch #3. Thanks for reporting and finding out this problem.

    I was developing branch 4.0.x on a Drupal 9 site and never tried it on Drupal 10. On Drupal 9 everything works fine and since I don't use deprecated Drupal API calls, then I expected that it should work on D10, too. It seems I was terribly wrong. Something about plugins are not the same in D10. TBH, I don't know why was this strange empty constructor there in the first place, this is leftover code from an older release by previous maintainers that I missed to review when working with it. Anyway, please check out the newest release, it should work now.

  • 🇮🇳India Vivek Panicker Kolkata

    Thanks for the explanation @simonbaese.

    @kaszarobert I think we should have an issue then to properly apply depdendency injection in the class files.

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

Production build 0.69.0 2024