wp_privacy_process_personal_data_export_page( array $response, int $exporter_index, string $email_address, int $page, int $request_id, bool $send_as_email, string $exporter_key ): array
- Since
- 4.9.6
- Source
wp-admin/includes/privacy-tools.php:775
Compatibility
- WordPress
- since 4.9.6
- 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 response from the personal data exporter for the given page.
$exporter_indexint- The index of the personal data exporter. Begins at 1.
$email_addressstring- The email address of the user whose personal data this is.
$pageint- The page of personal data for this exporter. Begins at 1.
$request_idint- The request ID for this personal data export.
$send_as_emailbool- Whether the final results of the export should be emailed to the user.
$exporter_keystring- The slug (key) of the exporter.
Return value
array- The filtered response.
Performance profile
How much work a call to wp_privacy_process_personal_data_export_page() 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
- Expensive
- Scaling
- Scales with input
- Instructions
- 10–104
- Plugin surface
- 2 hooks
- Called by
- 0
Sends mail via wp_mail().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 171.
Third-party callbacks on 'wp_privacy_personal_data_exporters', 'wp_privacy_personal_data_export_file' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - querycontent query
get_post()one call below wp_privacy_process_personal_data_export_page() - optionoption read or write
get_option()one call below wp_privacy_process_personal_data_export_page() - mailsends mail
wp_mail()one call below wp_privacy_process_personal_data_export_page()
Further down the call graph this can also reach serialize, cache 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 · 17 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_privacy_process_personal_data_export_page() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 10–17 | none |
is_array($response) && $response | 55–59 | wp_get_user_request(), get_post_meta(), array_merge(), update_post_meta(), apply_filters() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 | 56–57 | wp_get_user_request(), update_post_meta(), array_merge(), update_post_meta(), apply_filters() |
is_array($response) && $response | 58–65 | wp_get_user_request(), __(), wp_send_json_error(), get_post_meta(), array_merge(), update_post_meta(), apply_filters() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 | 59–63 | wp_get_user_request(), __(), wp_send_json_error(), update_post_meta(), array_merge(), update_post_meta(), apply_filters() |
is_array($response) && $response && $exporter_index === false && !is_wp_error() | 89–93 | wp_get_user_request(), get_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), _wp_privacy_completed_request() |
is_array($response) && $response && $exporter_index === false | 90–96 | wp_get_user_request(), get_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_exports_url(), get_post_meta() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 && $exporter_index === false && !is_wp_error() | 90–91 | wp_get_user_request(), update_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), _wp_privacy_completed_request() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 && $exporter_index === false | 91–94 | wp_get_user_request(), update_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_exports_url(), get_post_meta() |
is_array($response) && $response && $exporter_index === false && !is_wp_error() | 92–99 | wp_get_user_request(), __(), wp_send_json_error(), get_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), _wp_privacy_completed_request() |
is_array($response) && $response && $exporter_index === false | 93–102 | wp_get_user_request(), __(), wp_send_json_error(), get_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_exports_url(), get_post_meta() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 && $exporter_index === false && !is_wp_error() | 93–97 | wp_get_user_request(), __(), wp_send_json_error(), update_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), _wp_privacy_completed_request() |
5 further outcomes, up to 102 instructions
is_array($response) && $response && $exporter_index === 1 && $page === 1 && $exporter_index === false | 94–100 | wp_get_user_request(), __(), wp_send_json_error(), update_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_exports_url(), get_post_meta() |
is_array($response) && $response && $exporter_index === false && is_wp_error() | 94–98 | wp_get_user_request(), get_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), ->get_error_message(), wp_send_json_error(), _wp_privacy_completed_request() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 && $exporter_index === false && is_wp_error() | 95–96 | wp_get_user_request(), update_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), ->get_error_message(), wp_send_json_error(), _wp_privacy_completed_request() |
is_array($response) && $response && $exporter_index === false && is_wp_error() | 97–104 | wp_get_user_request(), __(), wp_send_json_error(), get_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), ->get_error_message(), wp_send_json_error(), _wp_privacy_completed_request() |
is_array($response) && $response && $exporter_index === 1 && $page === 1 && $exporter_index === false && is_wp_error() | 98–102 | wp_get_user_request(), __(), wp_send_json_error(), update_post_meta(), array_merge(), update_post_meta(), apply_filters(), delete_post_meta(), update_post_meta(), do_action(), delete_post_meta(), wp_privacy_send_personal_data_export_email(), is_wp_error(), ->get_error_message(), wp_send_json_error(), _wp_privacy_completed_request() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 171 instructions, 10–104 executed per call, 19 branches. The work does not change between versions.
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.
Hooks and filters fired · 2
2 hooks fire while wp_privacy_process_personal_data_export_page() runs, in this order:
- apply_filters( wp_privacy_personal_data_exporters )filterline 822 (+47 into the body)
Filters the array of exporter callbacks.
- do_action( wp_privacy_personal_data_export_file )actionline 871 (+96 into the body)
Generate the export file from the collected, grouped personal data.
Uses · 12
- wp_get_user_request()Returns the user request object for the specified request ID.
- wp_send_json_error()Sends a JSON response back to an Ajax request, indicating failure.
- __()Retrieves the translation of $text.
- update_post_meta()Updates a post meta field based on the given post ID.
- get_post_meta()Retrieves a post meta field for the given post ID.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- delete_post_meta()Deletes a post meta field for the given post ID.
- do_action()Calls the callback functions that have been added to an action hook.
- wp_privacy_send_personal_data_export_email()Send an email to the user with a link to the personal data export file
- is_wp_error()Checks whether the given variable is a WordPress Error.
- _wp_privacy_completed_request()Marks a request as completed by the admin and logs the current timestamp.
- wp_privacy_exports_url()Returns the URL of the directory used to store personal data export files.
Source code
function wp_privacy_process_personal_data_export_page( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ) { /* Do some simple checks on the shape of the response from the exporter. * If the exporter response is malformed, don't attempt to consume it - let it * pass through to generate a warning to the user by default Ajax processing. */ if ( ! is_array( $response ) ) { return $response; } if ( ! array_key_exists( 'done', $response ) ) { return $response; } if ( ! array_key_exists( 'data', $response ) ) { return $response; } if ( ! is_array( $response['data'] ) ) { return $response; } // Get the request. $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request ID when merging personal data to export.' ) ); } $export_data = array(); // First exporter, first page? Reset the report data accumulation array. if ( 1 === $exporter_index && 1 === $page ) { update_post_meta( $request_id, '_export_data_raw', $export_data ); } else { $accumulated_data = get_post_meta( $request_id, '_export_data_raw', true ); if ( $accumulated_data ) { $export_data = $accumulated_data; } } // Now, merge the data from the exporter response into the data we have accumulated already. $export_data = array_merge( $export_data, $response['data'] ); update_post_meta( $request_id, '_export_data_raw', $export_data ); // If we are not yet on the last page of the last exporter, return now. /** This filter is documented in wp-admin/includes/ajax-actions.php */ $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); $is_last_exporter = count( $exporters ) === $exporter_index; $exporter_done = $response['done']; if ( ! $is_last_exporter || ! $exporter_done ) { return $response; } // Last exporter, last page - let's prepare the export file. // First we need to re-organize the raw data hierarchically in groups and items. $groups = array(); foreach ( (array) $export_data as $export_datum ) { $group_id = $export_datum['group_id']; $group_label = $export_datum['group_label']; $group_description = ''; if ( ! empty( $export_datum['group_description'] ) ) { $group_description = $export_datum['group_description']; } if ( ! array_key_exists( $group_id, $groups ) ) { $groups[ $group_id ] = array( 'group_label' => $group_label, 'group_description' => $group_description, 'items' => array(), ); } $item_id = $export_datum['item_id']; if ( ! array_key_exists( $item_id, $groups[ $group_id ]['items'] ) ) { $groups[ $group_id ]['items'][ $item_id ] = array(); }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/privacy-tools.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.