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:3358
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
- Scaling
- Constant
- Instructions
- 11–39
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 46.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_post()one call below WP_Customize_Manager::check_changeset_lock_with_heartbeat() - hookthird-party callbacks
apply_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.
| When | Instructions | Calls 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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 46 | 11–39 | 6 | |
| 8.5 | 46 | 11–39 | 6 | |
| 8.4 | 46 | 11–39 | 6 | |
| 8.3 | 46 | 11–39 | 6 | |
| 8.2 | 46 | 11–39 | 6 | |
| 8.1 | 46 | 11–39 | 6 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 47 | 11–40 | 6 |
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
- current_user_can()Returns whether the current user has the specified capability.
- get_post_type_object()Retrieves a post type object by name.
- wp_check_post_lock()Determines whether the post is currently being edited by another user.
- WP_Customize_Manager::find_changeset_post_id()Finds the changeset post ID for a given changeset UUID.
- WP_Customize_Manager::changeset_post_id()Gets the changeset post ID for the loaded changeset.
- WP_Customize_Manager::get_lock_user_data()Gets lock user data.
- WP_Customize_Manager::refresh_changeset_lock()Refreshes changeset lock with the current time if current user edited the changeset before.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.