wppaste
WordPress

WP_Customize_Manager::check_changeset_lock_with_heartbeat( array $response, array $data, string $screen_id ): array

Since
4.9.0
Source
wp-includes/class-wp-customize-manager.php:3359
Checks locked changeset with heartbeat API.

Compatibility

WordPress
since 4.9.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

$responsearray
The Heartbeat response.
$dataarray
The $_POST data sent.
$screen_idstring
The screen id.

Return value

array
The Heartbeat response.

Performance profile

How much work a call to WP_Customize_Manager::check_changeset_lock_with_heartbeat() 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
11–39

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

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()one call below WP_Customize_Manager::check_changeset_lock_with_heartbeat()
  • hookthird-party callbacksapply_filters()one call below WP_Customize_Manager::check_changeset_lock_with_heartbeat()

Further down the call graph this can also reach cache, serialize, 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 · 8 distinct outcomes

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

WhenInstructionsCalls it makes
!isset($data)11–14->changeset_post_id()
isset($data)15–18->find_changeset_post_id()
!isset($data) && $data && $screen_id === "customize" && !current_user_can()25->changeset_post_id(), get_post_type_object(), current_user_can()
isset($data) && $data && $screen_id === "customize" && !current_user_can()29->find_changeset_post_id(), get_post_type_object(), current_user_can()
!isset($data) && $data && $screen_id === "customize" && current_user_can()33->changeset_post_id(), get_post_type_object(), current_user_can(), wp_check_post_lock(), ->refresh_changeset_lock()
!isset($data) && $data && $screen_id === "customize" && current_user_can()35->changeset_post_id(), get_post_type_object(), current_user_can(), wp_check_post_lock(), ->get_lock_user_data()
isset($data) && $data && $screen_id === "customize" && current_user_can()37->find_changeset_post_id(), get_post_type_object(), current_user_can(), wp_check_post_lock(), ->refresh_changeset_lock()
isset($data) && $data && $screen_id === "customize" && current_user_can()39->find_changeset_post_id(), get_post_type_object(), current_user_can(), wp_check_post_lock(), ->get_lock_user_data()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev4611–396
8.54611–396
8.44611–396
8.34611–396
8.24611–396
8.14611–3961 fewer instruction than PHP 7.4
7.44711–406

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

	public function check_changeset_lock_with_heartbeat( $response, $data, $screen_id ) {		if ( isset( $data['changeset_uuid'] ) ) {			$changeset_post_id = $this->find_changeset_post_id( $data['changeset_uuid'] );		} else {			$changeset_post_id = $this->changeset_post_id();		} 		if (			array_key_exists( 'check_changeset_lock', $data )			&& 'customize' === $screen_id			&& $changeset_post_id			&& current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id )		) {			$lock_user_id = wp_check_post_lock( $changeset_post_id ); 			if ( $lock_user_id ) {				$response['customize_changeset_lock_user'] = $this->get_lock_user_data( $lock_user_id );			} else { 				// Refreshing time will ensure that the user is sitting on customizer and has not closed the customizer tab.				$this->refresh_changeset_lock( $changeset_post_id );			}		} 		return $response;	}

Changelog

Introduced in 4.9.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.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-customize-manager.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.