Skip to content
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

[PHP 8.1 compatibility] Deprecated - preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in Draw.php(2302) #20655

Closed
tsteur opened this issue May 3, 2023 · 4 comments · Fixed by #20806
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented May 3, 2023

vendor/szymach/c-pchart/src/Draw.php(2302): Deprecated - preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated - Matomo 4.14.3-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) [internal function]: Piwik\ErrorHandler::errorHandler(),#1/vendor/szymach/c-pchart/src/Draw.php(2302),#2/plugins/ImageGraph/StaticGraph/GridGraph.php(312),#3/plugins/ImageGraph/StaticGraph/Evolution.php(24),#4/plugins/ImageGraph/API.php(506),[internal function]: Piwik\Plugins\ImageGraph\API->get(),#6/core/API/Proxy.php(244),#7/core/Context.php(28),#8/core/API/Proxy.php(335),#9/core/API/Request.php(267)

After upgrading to PHP 8.1 above warning is showing up in the logs. This is all the information we have.

@tsteur tsteur added Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels May 3, 2023
@michalkleiner
Copy link
Contributor

Hi @tsteur,
thanks for reporting this. I've checked and we are using the latest version of szymach/c-pchart that draws the graphs and this issue may occur when the data series to display doesn't have a description which is attempted to be split into lines of text.

This issue is the same problem as #20656 so I will mark that one as a duplicate and we'll address all occurrences of the same code (preg_split("/\n/", $Serie["Description"]);) together. We will need to make sure we always pass at least an empty string, not a null as the data series description.

@michalkleiner michalkleiner added Bug For errors / faults / flaws / inconsistencies etc. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. To Triage An issue awaiting triage by a Matomo core team member labels May 4, 2023
@michalkleiner michalkleiner added this to the For Prioritization milestone May 4, 2023
@sgiehl
Copy link
Member

sgiehl commented May 4, 2023

@michalkleiner As the description should actually not be a required property of a data series, this might also be a a bug in szymach/c-pchart. We can also try to create a PR there and try to get that merged. I've already provided a couple of fixes for that lib...

@michalkleiner
Copy link
Contributor

Yes, that's a good point. We can approach it from either direction — either make sure we always pass at least an empty string (not a null value) or submit a PR for the c-pchart dependency to correctly handle optional descriptions with null coalesce operator.

@sgiehl
Copy link
Member

sgiehl commented May 30, 2023

Had another look through the code and it seems it's actually a problem on our side and not the library. The library automatically sets the Description if new datapoints are added. But I found a place where it can happen that the description is overwritten with null on our side. Will propose a PR to fix that.

@sgiehl sgiehl modified the milestones: For Prioritization, 5.0.0 May 30, 2023
@sgiehl sgiehl self-assigned this Jun 7, 2023
@michalkleiner michalkleiner changed the title PHP 8.1 incompatibility - Deprecated - preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in Draw.php(2302) [PHP 8.1 compatibility] - Deprecated - preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in Draw.php(2302) Jun 9, 2023
@michalkleiner michalkleiner changed the title [PHP 8.1 compatibility] - Deprecated - preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in Draw.php(2302) [PHP 8.1 compatibility] Deprecated - preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in Draw.php(2302) Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants