fix: avoid Passing null to parameter is deprecated messages#225
Open
phil-davis wants to merge 1 commit into
Open
fix: avoid Passing null to parameter is deprecated messages#225phil-davis wants to merge 1 commit into
phil-davis wants to merge 1 commit into
Conversation
trim() in PHP8 requires a string to be passed. Passing null is deprecated, and a deprecation message is emitted. For example: trim(): Passing null to parameter #1 ($string) of type string is deprecated at \/var\/www\/html\/server\/apps\/testing\/lib\/ServerFiles.php#143 Avoid these by ensuring that the value passed to trim() is always a string. Return appropriate "Bad Request" 400 status in the cases where an expected value was not provided.
a75ede1 to
afecfe4
Compare
phil-davis
commented
Jul 11, 2026
| */ | ||
| public function rmDir() { | ||
| $dir = \trim($this->request->getParam('dir'), '/'); | ||
| $dir = \trim($this->request->getParam('dir', ''), '/'); |
Contributor
Author
There was a problem hiding this comment.
These changes to the call to getParam add a default value of the empty string.
That ensures that the empty string will be passed to trim if the Param does not exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
trim() in PHP8 requires a string to be passed. Passing null is deprecated, and a deprecation message is emitted.
For example:
trim(): Passing null to parameter #1 ($string) of type string is deprecated at /var/www/html/server/apps/testing/lib/ServerFiles.php#143
Avoid these by ensuring that the value passed to trim() is always a string. Return appropriate "Bad Request" 400 status in the cases where an expected value was not provided.
https://github.com/owncloud/core/actions/runs/29151644976/job/86542673266?pr=41676#logs had this sort of thing in the log file. It will be good to avoid cluttering the log file.