Skip to content

fix(block-migrate): remove unnecessary pass-by-reference on WP_Post - #2666

Open
faisalahammad wants to merge 1 commit into
godaddy-wordpress:masterfrom
faisalahammad:fix/2662-the-post-pbr-warning
Open

fix(block-migrate): remove unnecessary pass-by-reference on WP_Post#2666
faisalahammad wants to merge 1 commit into
godaddy-wordpress:masterfrom
faisalahammad:fix/2662-the-post-pbr-warning

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Jul 30, 2026

Copy link
Copy Markdown

Description

Fixes #2662

The the_post callback in includes/block-migrate/loader.php declared WP_Post &$post as pass-by-reference. Since WP_Post is an object in PHP, it is already passed by handle to closures - the & is unnecessary and generates a PHP 8.x warning because WP_Hook::apply_filters() passes arguments by value.

Screenshots

Not applicable.

Types of changes

Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Confirmed the warning no longer appears in PHP 8.3 error logs. WP_Post is an object, so removing the reference does not affect the closure's ability to mutate $post->post_content (line 60).

Acceptance criteria

PHP 8.x warning on every page load is removed.

Checklist:

  • My code is tested
  • My code follows accessibility standards
  • My code has proper inline documentation
  • I've included any necessary tests
  • I've included developer documentation
  • I've added proper labels to this pull request

WP_Post is an object, already passed by handle to closures. The &
on the the_post callback parameter was redundant and triggers a
PHP 8.x warning because WP_Hook::apply_filters() passes arguments
by value.

Fixes godaddy-wordpress#2662
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.

PHP 8.x warning: pass-by-reference parameter in block-migrate/loader.php closure

1 participant