wppaste
WordPress

update_ignored_hooked_blocks_postmeta( stdClass $post ): stdClass

Since
6.6.0, 6.8.0
Source
wp-includes/blocks.php:1352
Updates the wp_postmeta with the list of ignored hooked blocks where the inner blocks are stored as post content.

Compatibility

WordPress
since 6.8.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$poststdClass
Post object.

Return value

stdClass
The updated post object.

Performance profile

How much work a call to update_ignored_hooked_blocks_postmeta() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
4–119

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 126.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • querycontent queryget_post()called directly
  • serializeserialisationjson_decode()called directly
  • hookthird-party callbacksapply_filters()one call below update_ignored_hooked_blocks_postmeta()

Further down the call graph this can also reach cache, option and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 7 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost update_ignored_hooked_blocks_postmeta() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always4–8none
!empty($post) && isset($post) && empty($ignored_hooked_blocks)72–78get_post_meta(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), remove_serialized_parent_block()
!empty($post) && isset($post)80–86get_post_meta(), json_decode(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), remove_serialized_parent_block()
!empty($post) && isset($post) && empty($existing_ignored_hooked_blocks)90–98get_post_meta(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_encode(), remove_serialized_parent_block()
!empty($post) && isset($post) && !empty($ignored_hooked_blocks) && empty($existing_ignored_hooked_blocks)98–106get_post_meta(), json_decode(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_encode(), remove_serialized_parent_block()
!empty($post) && isset($post) && !empty($existing_ignored_hooked_blocks)103–111get_post_meta(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_decode(), array_merge(), array_unique(), json_encode(), remove_serialized_parent_block()
!empty($post) && isset($post) && !empty($ignored_hooked_blocks) && !empty($existing_ignored_hooked_blocks)111–119get_post_meta(), json_decode(), get_comment_delimited_block_content(), get_post(), array_merge(), ignoredHookedBlocks(), apply_block_hooks_to_content(), parse_blocks(), get_post_meta(), json_decode(), array_merge(), array_unique(), json_encode(), remove_serialized_parent_block()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1264–11910
8.51264–11910
8.41264–11910
8.31264–11910
8.21264–11910
8.11264–119101 fewer instruction than PHP 7.4
7.41274–12010

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 7

Source code

function update_ignored_hooked_blocks_postmeta( $post ) {	/*	 * In this scenario the user has likely tried to create a new post object via the REST API.	 * In which case we won't have a post ID to work with and store meta against.	 */	if ( empty( $post->ID ) ) {		return $post;	} 	/*	 * Skip meta generation when consumers intentionally update specific fields	 * and omit the content update.	 */	if ( ! isset( $post->post_content ) ) {		return $post;	} 	/*	 * Skip meta generation if post type is not set.	 */	if ( ! isset( $post->post_type ) ) {		return $post;	} 	$attributes = array(); 	$ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );	if ( ! empty( $ignored_hooked_blocks ) ) {		$ignored_hooked_blocks  = json_decode( $ignored_hooked_blocks, true );		$attributes['metadata'] = array(			'ignoredHookedBlocks' => $ignored_hooked_blocks,		);	} 	if ( 'wp_navigation' === $post->post_type ) {		$wrapper_block_type = 'core/navigation';	} elseif ( 'wp_block' === $post->post_type ) {		$wrapper_block_type = 'core/block';	} else {		$wrapper_block_type = 'core/post-content';	} 	$markup = get_comment_delimited_block_content(		$wrapper_block_type,		$attributes,		$post->post_content	); 	$existing_post = get_post( $post->ID );	// Merge the existing post object with the updated post object to pass to the block hooks algorithm for context.	$context          = (object) array_merge( (array) $existing_post, (array) $post );	$context          = new WP_Post( $context ); // Convert to WP_Post object.	$serialized_block = apply_block_hooks_to_content( $markup, $context, 'set_ignored_hooked_blocks_metadata' );	$root_block       = parse_blocks( $serialized_block )[0]; 	$ignored_hooked_blocks = isset( $root_block['attrs']['metadata']['ignoredHookedBlocks'] )		? $root_block['attrs']['metadata']['ignoredHookedBlocks']		: array(); 	if ( ! empty( $ignored_hooked_blocks ) ) {		$existing_ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );		if ( ! empty( $existing_ignored_hooked_blocks ) ) {			$existing_ignored_hooked_blocks = json_decode( $existing_ignored_hooked_blocks, true );			$ignored_hooked_blocks          = array_unique( array_merge( $ignored_hooked_blocks, $existing_ignored_hooked_blocks ) );		} 		if ( ! isset( $post->meta_input ) ) {			$post->meta_input = array();		}		$post->meta_input['_wp_ignored_hooked_blocks'] = json_encode( $ignored_hooked_blocks );	} 	$post->post_content = remove_serialized_parent_block( $serialized_block );	return $post;}

Changelog

Introduced in 6.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.8.0
Support non-wp_navigation post types.from the docblock
6.6.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/blocks.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.