WP_Privacy_Requests_Table::prepare_items()
- Since
- 4.9.6, 5.1.0
- Source
wp-admin/includes/class-wp-privacy-requests-table.php:367
Compatibility
- WordPress
- since 5.1.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.
Performance profile
How much work a call to WP_Privacy_Requests_Table::prepare_items() 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
- Scales with input
- Instructions
- 55–109
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_post().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 121.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Privacy_Requests_Table::prepare_items() - querycontent query
get_post()one call below WP_Privacy_Requests_Table::prepare_items()
Further down the call graph this can also reach option, cache, serialize 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 · 22 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Privacy_Requests_Table::prepare_items() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($value) | 55–72 | ->get_items_per_page(), array_filter(), total_items() |
| always | 62–79 | ->get_items_per_page(), sanitize_text_field(), array_filter(), total_items() |
| always | 62–79 | ->get_items_per_page(), strtoupper(), array_filter(), total_items() |
| always | 64–81 | ->get_items_per_page(), absint(), array_filter(), total_items() |
| always | 69–86 | ->get_items_per_page(), strtoupper(), strtoupper(), array_filter(), total_items() |
| always | 69–86 | ->get_items_per_page(), sanitize_text_field(), strtoupper(), array_filter(), total_items() |
| always | 71–88 | ->get_items_per_page(), absint(), sanitize_text_field(), array_filter(), total_items() |
| always | 71–88 | ->get_items_per_page(), absint(), strtoupper(), array_filter(), total_items() |
!empty($value) | 76–86 | ->get_items_per_page(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
!empty($value) | 76–86 | ->get_items_per_page(), sanitize_text_field(), sanitize_text_field(), array_filter(), total_items() |
| always | 76–93 | ->get_items_per_page(), sanitize_text_field(), strtoupper(), strtoupper(), array_filter(), total_items() |
| always | 78–95 | ->get_items_per_page(), absint(), strtoupper(), strtoupper(), array_filter(), total_items() |
10 further outcomes, up to 109 instructions
isset($value) | 78–95 | ->get_items_per_page(), absint(), sanitize_text_field(), strtoupper(), array_filter(), total_items() |
!empty($value) | 83–93 | ->get_items_per_page(), strtoupper(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
!empty($value) | 83–93 | ->get_items_per_page(), sanitize_text_field(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
!empty($value) | 85–95 | ->get_items_per_page(), absint(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
!empty($value) | 85–95 | ->get_items_per_page(), absint(), sanitize_text_field(), sanitize_text_field(), array_filter(), total_items() |
isset($value) | 85–102 | ->get_items_per_page(), absint(), sanitize_text_field(), strtoupper(), strtoupper(), array_filter(), total_items() |
!empty($value) | 90–100 | ->get_items_per_page(), sanitize_text_field(), strtoupper(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
!empty($value) | 92–102 | ->get_items_per_page(), absint(), strtoupper(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
isset($value) && !empty($value) | 92–102 | ->get_items_per_page(), absint(), sanitize_text_field(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
isset($value) && !empty($value) | 99–109 | ->get_items_per_page(), absint(), sanitize_text_field(), strtoupper(), strtoupper(), sanitize_text_field(), array_filter(), total_items() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 119 | 55–107 | 10 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 121 | 55–109 | 10 | |
| 8.4 | 121 | 55–109 | 10 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 124 | 55–112 | 10 | |
| 8.2 | 124 | 55–112 | 10 | |
| 8.1 | 124 | 55–112 | 10 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 125 | 55–113 | 10 |
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 · 6
- absint()Converts a value to non-negative integer.
- sanitize_text_field()Sanitizes a string from user input or from the database.
- wp_get_user_request()Returns the user request object for the specified request ID.
- WP_Privacy_Requests_Table::get_items_per_page()
- WP_Query::__construct()Constructor.
- WP_Privacy_Requests_Table::set_pagination_args()
Source code
public function prepare_items() { $this->items = array(); $posts_per_page = $this->get_items_per_page( $this->request_type . '_requests_per_page' ); $args = array( 'post_type' => $this->post_type, 'post_name__in' => array( $this->request_type ), 'posts_per_page' => $posts_per_page, 'offset' => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page : 0, 'post_status' => 'any', 's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '', ); $orderby_mapping = array( 'requester' => 'post_title', 'requested' => 'post_date', ); if ( isset( $_REQUEST['orderby'] ) && isset( $orderby_mapping[ $_REQUEST['orderby'] ] ) ) { $args['orderby'] = $orderby_mapping[ $_REQUEST['orderby'] ]; } if ( isset( $_REQUEST['order'] ) && in_array( strtoupper( $_REQUEST['order'] ), array( 'ASC', 'DESC' ), true ) ) { $args['order'] = strtoupper( $_REQUEST['order'] ); } if ( ! empty( $_REQUEST['filter-status'] ) ) { $filter_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : ''; $args['post_status'] = $filter_status; } $requests_query = new WP_Query( $args ); $requests = $requests_query->posts; foreach ( $requests as $request ) { $this->items[] = wp_get_user_request( $request->ID ); } $this->items = array_filter( $this->items ); $this->set_pagination_args( array( 'total_items' => $requests_query->found_posts, 'per_page' => $posts_per_page, ) ); }Changelog
Introduced in 4.9.6. 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-admin/includes/class-wp-privacy-requests-table.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.