Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#54670 closed defect (bug) (fixed)

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

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


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.

2 years 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: [](

#3 @hellofromTonya
2 years ago

  • Keywords commit added

Marking PR 2072 for commit.

Opened an issue in the Gutenberg repository to backport the changes to Gutenberg

#4 @hellofromTonya
2 years ago

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

Self-assigning to prepare the commit.

#5 @hellofromTonya
2 years 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.


Follow-up to [52062].

Props jrf.
Fixes #54670.

Note: See TracTickets for help on using tickets.