wppaste
WordPress

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
Intercept personal data exporter page Ajax responses in order to assemble the personal data export file.

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

Sends mail via wp_mail().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
10–104

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

Plugin surface
2 hooks

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.

Called by
0

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

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_post()one call below wp_privacy_process_personal_data_export_page()
  • optionoption read or writeget_option()one call below wp_privacy_process_personal_data_export_page()
  • mailsends mailwp_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.

WhenInstructionsCalls it makes
always10–17none
is_array($response) && $response55–59wp_get_user_request(), get_post_meta(), array_merge(), update_post_meta(), apply_filters()
is_array($response) && $response && $exporter_index === 1 && $page === 156–57wp_get_user_request(), update_post_meta(), array_merge(), update_post_meta(), apply_filters()
is_array($response) && $response58–65wp_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 === 159–63wp_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–93wp_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 === false90–96wp_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–91wp_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 === false91–94wp_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–99wp_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 === false93–102wp_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–97wp_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 === false94–100wp_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–98wp_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–96wp_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–104wp_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–102wp_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:

  1. apply_filters( wp_privacy_personal_data_exporters )filterline 822 (+47 into the body)

    Filters the array of exporter callbacks.

  2. 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

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.

  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 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.