Skip to content

Conversation

@obenland
Copy link
Member

Proposed changes:

  • Fixed PHP 8.4 deprecation warnings caused by passing null values to WordPress core functions
  • Cast values to string in get_summary() methods for User, Blog, and Application models before passing to wp_kses()
  • Added null coalescing operators in Actors collection for get_name() and get_summary() calls to provide empty string fallbacks
  • Updated sanitize callback in ActivityPub class to cast input to string before wp_kses() processing
  • These changes prevent "Passing null to parameter of type string" deprecation warnings in PHP 8.4

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Set up a local WordPress environment with PHP 8.4
  • Enable WordPress debugging by adding these lines to wp-config.php:
    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', true);
  • Install and activate the ActivityPub plugin
  • Create or edit a user profile with an empty bio/description field
  • Create a blog post and view it in the frontend
  • Check for PHP deprecation warnings in the debug log or on screen
  • Before this fix: Multiple "Passing null to parameter Catchall-Account #1 ($content) of type string" warnings would appear
  • After this fix: No deprecation warnings should appear when handling null values in user descriptions, blog summaries, or ActivityPub content processing

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Fix PHP 8.4 deprecation warnings by preventing null values from being passed to WordPress core functions

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.
Copilot AI review requested due to automatic review settings August 20, 2025 19:36
@obenland obenland self-assigned this Aug 20, 2025
@obenland obenland requested a review from pfefferle August 20, 2025 19:36

This comment was marked as outdated.

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
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.
@obenland obenland requested a review from Copilot August 21, 2025 13:09
Copy link

Copilot AI left a 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.

@obenland obenland merged commit 9b48d90 into trunk Aug 21, 2025
13 checks passed
@obenland obenland deleted the fix/php-8.4-deprecation-warnings branch August 21, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants