New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IniReader::readWithNativeFunction chokes on multi-line strings #15689
Comments
@skizzerz what messages appears in your logs? And does Matomo otherwise still function for you? If you have an example config that be great too. Or I assume it be like
? |
@tsteur Matomo still functions normally as far as I can tell because it falls back to what was read from the initial The logs all look like the following (sometimes the type is bool instead of null)
Line number may be a bit off because I manually patched the file to suppress the warning in the meantime. The error is referring to this line of code: https://github.com/matomo-org/component-ini/blob/master/src/IniReader.php#L353 My patch was in the readNativeFunction method: $rawValues = @parse_ini_string($ini, true, INI_SCANNER_RAW);
if ($rawValues === false) {
return $this->decode($array, $array);
}
$array = $this->decode($array, $rawValues); I can submit that as a PR if desired, but I held off on that because of the doc comments in decode() about the default parse_ini_file method not working correctly in some instances. As this would effectively use that method without checking values, it may introduce regressions in other areas (namely, whatever cased you to start using the raw scanner and decode method in the first place). That config you posted should reproduce the issue. |
I can confirm the issue. I was thinking disabling the method I think your patch should work and be safe. Looking at http://3v4l.org/m24cT it might not even be needed anymore in general since it only affected older versions of PHP by the looks. Would you mind creating a PR for our 4.x-dev branch? |
In some cases (such as when the ini file contains multi-line strings), parse_ini_file with the INI_SCANNER_RAW flag causes the parse to fail. This in turn leads to a lot of noise in error logs because the subsequent call to decode throws a lot of E_NOTICEs. If the parse fails, just use what was processed by parse_ini_file directly instead. See matomo-org/matomo#15689 for additional context.
The file was part of a composer component, PR opened against the dev branch of that repo instead. |
parse_ini_string($ini, true, INI_SCANNER_RAW)
returnsfalse
if the ini string being parsed contains a multi-line quoted string, citing a syntax error in the ini. WithoutINI_SCANNER_RAW
the parse succeeds and it properly reads the multi-line string.While this is quite possibly a bug in PHP itself, it's causing a lot of noise in the error logs because matomo isn't checking the return value of this function call and just assumes it succeeds.
To easily reproduce, just have some configuration which requires multiple lines. In my case, it was the LoginSaml configuration to specify server certificates (idp_x509cert, advanced_sp_x509cert, and advanced_sp_privatekey). However, you can probably reproduce this by manually editing the file and just inserting any arbitrary multi-line configuration
The text was updated successfully, but these errors were encountered: