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')).
Comments
Comment #4
sleitner commentedComment #6
grimreaperHello,
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?
Comment #8
t_stallmann commentedI'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.
Comment #9
grimreaperComment #11
grimreaperManually re-commited to fix commit message.
Thanks!