-
Notifications
You must be signed in to change notification settings - Fork 84
Fix PHP 8.4 deprecation warnings with null parameter handling #2085
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
Conversation
Prevent null values from being passed to wp_kses() and wp_strip_all_tags() which cause "Passing null to parameter of type string" deprecation warnings in PHP 8.4. Changes: - Cast return values to string in get_summary() methods - Add null coalescing operators where needed - Fix sanitize callbacks to handle null input
Simplified the rendering of the actor summary by removing the unnecessary null coalescing operator, as the existence of the summary is already checked.
Address deprecation warnings for null parameters passed to WordPress core functions: - Cast null values to string for wp_parse_url() calls - Cast null values to string for preg_match() calls - Cast null values to string for explode() calls - Cast null values to string for ltrim() calls
…/Automattic/wordpress-activitypub into fix/php-8.4-deprecation-warnings
This reverts commit 5f59d27.
Refactored Test_Announce to remove reliance on instance user_url and post_permalink in static methods, using static data instead. Updated filter callbacks to use instance methods, and adjusted test data creation for consistency. Also added 'actor' field to the test object in Test_Inbox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes PHP 8.4 deprecation warnings caused by passing null values to WordPress core functions that expect string parameters. The changes ensure type safety by casting potentially null values to strings before passing them to functions like wp_kses().
Key Changes:
- Added string casting in model classes (User, Blog, Application) to prevent null values from being passed to
wp_kses() - Added null coalescing operators in the Actors collection to provide empty string fallbacks
- Updated sanitize callback in ActivityPub class to cast input to string before processing
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| includes/model/class-user.php | Cast description to string before wp_kses() processing |
| includes/model/class-blog.php | Cast summary to string and simplified wp_kses() call |
| includes/model/class-application.php | Cast bloginfo description to string and simplified wp_kses() call |
| includes/collection/class-actors.php | Added null coalescing operators for get_name() and get_summary() calls |
| includes/class-activitypub.php | Cast value to string in sanitize callback before wp_kses() |
| tests/includes/handler/class-test-inbox.php | Added actor field to test data array |
| tests/includes/handler/class-test-announce.php | Refactored test methods and removed unused properties |
| .github/changelog/2085-from-description | Added changelog entry for the fix |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Proposed changes:
Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Fix PHP 8.4 deprecation warnings by preventing null values from being passed to WordPress core functions