Warning - preg_match(): Unknown modifier 'p' - Piwik 2.13.1


(Daryl Williams) #1

Just started getting this message this morning after changing a trusted host entry to reflect the piwik location on our site. The trusted host entries in the config file look like this:

trusted_hosts[] = "unform.com/piwik"
trusted_hosts[] = “unform.com

We are running Piwik version 2.13.1 on a cents 6.6. Any help would be much appreciated.

Thanks,

Daryl


(Daryl Williams) #2

To answer my own question it was the ‘/’ directory separator in the trusted host path to Piwik:

trusted_hosts[] = “unform.com/piwik

that caused the warning: “preg_match(): Unknown modifier ‘p’”

causing the p in piwik to appear as a modifier to the preg_match function.

I added the following line of code right before the line causing the error (line 252) to escape the forward slash and got rid of the warning:

$trustedHosts = preg_replace("///", “\/”, $trustedHosts);

Of course now I dont know if this will adversely affect Piwik somewhere else, but I guess I’ll find out…


(Matthieu Aubry) #3

Hi Daryl,

Thanks for the report and patch. I’ve fixed the bug in: Warning - preg_match(): Unknown modifier ‘a’ · Issue #8290 · matomo-org/piwik · GitHub

It is fixed in latest 2.14.0-RC4