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

Fix Deprecation Warning for trim() Function in awkExistsAndRunsCorrectly() #20969

Merged
merged 2 commits into from
Jul 7, 2023

Conversation

mindbreaker
Copy link
Contributor

@mindbreaker mindbreaker commented Jul 5, 2023

Description:

This pull request addresses a deprecation warning that arises when a null value is passed to the trim() function in the awkExistsAndRunsCorrectly() method.

Changes:

  • Added a ternary check to ensure that the trim() function is only called if the output from the shell command is not null.
    
  • If the output is null, the function will now return false.
    

This change prevents the deprecation warning and ensures compatibility with the updated behavior of the trim() function in PHP.

fixes #20959

Review

@michalkleiner
Copy link
Contributor

Thanks for the PR, @mindbreaker. The usual approach is to use the null-coalesce operator ?? that ensures a fallback value is provided when the tested value is null. Could you update the code as suggested? I'd be happy to merge it then.

@michalkleiner michalkleiner added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jul 5, 2023
Co-authored-by: Michal Kleiner <mk@011.nz>
@sgiehl sgiehl added this to the 5.0.0 milestone Jul 7, 2023
@sgiehl sgiehl merged commit 7b2fa56 into matomo-org:5.x-dev Jul 7, 2023
18 of 20 checks passed
@sgiehl
Copy link
Member

sgiehl commented Jul 7, 2023

Thanks @mindbreaker for your contribution 🎉

@FabianSchmick
Copy link

Can this fix also please be merged into the current maintained Version 4.x ?

sgiehl pushed a commit that referenced this pull request Oct 30, 2023
…tly() (#20969)

* Update Process.php

* Update: Use null-coalesce operator for null values

Co-authored-by: Michal Kleiner <mk@011.nz>

---------

Co-authored-by: Michal Kleiner <mk@011.nz>
@sgiehl
Copy link
Member

sgiehl commented Oct 30, 2023

@FabianSchmick I've just cherry-picked that to 4.x, so it will be included in the next release there as well.

@FabianSchmick
Copy link

Great! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PHP 8.1 compatibility] Deprecated - trim(): Passing null to parameter #1 ($string) of type string
4 participants