Skip to content

fix: avoid Passing null to parameter is deprecated messages#225

Open
phil-davis wants to merge 1 commit into
masterfrom
avoid-deprecated-trim
Open

fix: avoid Passing null to parameter is deprecated messages#225
phil-davis wants to merge 1 commit into
masterfrom
avoid-deprecated-trim

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

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.

@phil-davis phil-davis requested a review from a team as a code owner July 11, 2026 15:33
@phil-davis phil-davis requested a review from saw-jan July 11, 2026 15:33
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.
@phil-davis phil-davis force-pushed the avoid-deprecated-trim branch from a75ede1 to afecfe4 Compare July 11, 2026 16:10
Comment thread lib/ServerFiles.php
*/
public function rmDir() {
$dir = \trim($this->request->getParam('dir'), '/');
$dir = \trim($this->request->getParam('dir', ''), '/');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant