Problem/Motivation

The website encountered an unexpected error. Please try again later.
TypeError: preg_match() expects parameter 2 to be string, null given in preg_match() (line 70 of modules/contrib/matomo/matomo.install).

Similar for line 68 of matomo.module
status report

Steps to reproduce

Enable matomo module 8.x-1.11. Update to 8.x-1.12. Visit sites pages, e.g. aadmin/config, get fatal error.

Proposed resolution

$config->get('site_id') is passed to preg_match without checking a value is assigned. Code should check isset($config->get('site_id')).

Issue fork matomo-3244779

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

jonathan_hunt created an issue. See original summary.

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

sleitner’s picture

Status: Active » Needs review

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

grimreaper’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hello,

Thanks for the report and the MR but I am not able to reproduce the bug.

I tried to uninstall and reinstall a Matomo 8.x-1.12.

Then uninstall, downgrade to Matomo 8.x-1.11, enable, then update the module.

In both cases "$config->get('site_id')" is an empty string and not NULL.

Did you have existing config before and somehow it had been imported with a NULL and no more an empty string such as the default settings file do?

Or do you have an override in your settings.php that is not a string?

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

t_stallmann’s picture

I'm also seeing this error manifesting as a white-screen-of-death on a staging site after having just updated matomo module to the latest version.

Noticing that this same bug also comes up in the matomo.module file. Since the documented behavior of $config->get is to return NULL in cases where a key doesn't exist it seems useful to handle null values in the module here, just in case. Updated patch to handle both cases and to use the null coalescing operator.

grimreaper’s picture

Assigned: Unassigned » grimreaper
Status: Postponed (maintainer needs more info) » Needs review

  • Grimreaper committed 437019c on 8.x-1.x authored by t_stallmann
    Issue #3244779 by sleitner, Grimreaper, t_stallmann, jonathan_hunt: PHP...
  • Grimreaper committed fe566bb on 8.x-1.x authored by sleitner
    Issue #3244779 by sleitner, Grimreaper, t_stallmann, jonathan_hunt: PHP...
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed

Manually re-commited to fix commit message.

Thanks!

Status: Fixed » Closed (fixed)

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