WordPress.org

Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#54670 closed defect (bug) (fixed)

Gutenberg / newly introduced functions referring to non-existent class properties

Reported by: jrf Owned by: hellofromTonya
Milestone: 5.9 Priority: normal
Severity: normal Version: trunk
Component: Editor Keywords: has-patch commit
Focuses: Cc:

Description

Commit [52062] in response to ticket #54335 introduced the _build_block_template_result_from_file() and _build_block_template_result_from_post() functions in the wp-includes/block-template-utils.php file.

These functions directly set properties on the WP_Block_Template class, but are assigning to some properties which don't exist on the class.

This should be fixed.

Change History (6)

This ticket was mentioned in PR #2072 on WordPress/wordpress-develop by jrfnl.


5 weeks ago

The $post_types and $area properties are being assigned to from the _build_block_template_result_from_file() and _build_block_template_result_from_post() functions, which were introduced in WP 5.9, but these properties do not explicitly exist on the WP_Block_Template class.

Trac ticket: [](https://core.trac.wordpress.org/ticket/54670)

#3 @hellofromTonya
5 weeks ago

  • Keywords commit added

Marking PR 2072 for commit.

Opened an issue in the Gutenberg repository to backport the changes to Gutenberg https://github.com/WordPress/gutenberg/issues/37533.

#4 @hellofromTonya
5 weeks ago

  • Owner set to hellofromTonya
  • Status changed from new to reviewing

Self-assigning to prepare the commit.

#5 @hellofromTonya
5 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 52397:

Editor: Explicitly declare $post_types and $area properties in WP_Block_Template class.

The $post_types and $area properties are assigned in the _build_block_template_result_from_file() and _build_block_template_result_from_post() functions. However, neither property was explicitly declared in the WP_Block_Template class.

This commit explicitly declares both properties in the class. Why? (1) To make the code more readable and maintainable; (2) to avoid a Deprecated: Creation of dynamic property WP_Block_Template::$post_types is deprecated deprecation when PHP 8.2 is released.

Ref:

Follow-up to [52062].

Props jrf.
Fixes #54670.

Note: See TracTickets for help on using tickets.