Skip to content

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

@austinginder

Description

@austinginder

Description

The the_post callback in includes/block-migrate/loader.php:29 declares its parameter as pass-by-reference:

function( WP_Post &$post ) {

WordPress's WP_Hook::apply_filters() passes arguments by value, so this generates a warning on every page load under PHP 8.x:

PHP Warning: CoBlocks::{closure}(): Argument #1 ($post) must be passed by reference, value given in wp-includes/class-wp-hook.php on line 343

Steps to Reproduce

  1. Activate CoBlocks on PHP 8.x
  2. Visit any post/page on the frontend
  3. Check the error log

Fix

Remove the & from the closure parameter. Since WP_Post is an object, it's already passed by handle — the reference is unnecessary.

- function( WP_Post &$post ) {
+ function( WP_Post $post ) {

Environment

  • CoBlocks 3.1.17
  • PHP 8.3
  • WordPress 6.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions