Skip to content

Fix Deprecated Warning for trim() on Null Values #20

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

izzygld
Copy link

@izzygld izzygld commented Mar 12, 2025

Fix Deprecated Warning for trim() on Null Values

Description

This PR resolves a PHP 8.1+ deprecation warning caused by passing null to trim() in the redirect() function. The issue resulted in the following error:

PHP Deprecated: trim(): Passing null to parameter ($string) of type string is deprecated

Fix

  • Cast $userrequest and $storedrequest to (string) before passing them to trim().
  • Ensures compatibility with newer PHP versions while maintaining expected behavior.

Changes

Updated the redirect() function:

} elseif (urldecode(trim((string) $userrequest, '/')) == trim((string) $storedrequest, '/')) {

Testing
Verified that redirects still function correctly.
Tested under PHP 7.x and 8.x to ensure compatibility.
Impact
✅ Eliminates the deprecation notice.
✅ Prevents potential issues in future PHP releases.

Let me know if any additional changes are needed! 🚀

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