wppaste
WordPress

wp_comments_personal_data_exporter( string $email_address, int $page = 1 ): array

Since
4.9.6
Source
wp-includes/comment.php:3786
Finds and exports personal data associated with an email address from the comments table.

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

$email_addressstring
The comment author email address.
$pageintoptional
Comment page number.Default: 1

Return value

array
An array of personal data.
  • $dataarray[]

    An array of personal data arrays.
  • $donebool

    Whether the exporter is finished.

Performance profile

How much work a call to wp_comments_personal_data_exporter() 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_comments().

Scaling
Scales with input

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

Instructions
56–57

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

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_comments()called directly
  • hookthird-party callbacksapply_filters()one call below wp_comments_personal_data_exporter()
  • optionoption read or writeget_option()one call below wp_comments_personal_data_exporter()

Further down the call graph this can also reach 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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always56–57author_email(), __(), __(), __(), __(), __(), __(), __(), __()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev13256–5714
8.513256–5714
8.413256–5714
8.313256–5714
8.213256–57141 more instruction than PHP 8.1
8.113156–5714
7.413156–5714

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

Source code

function wp_comments_personal_data_exporter( $email_address, $page = 1 ) {	// Limit us to 500 comments at a time to avoid timing out.	$number = 500;	$page   = (int) $page; 	$data_to_export = array(); 	$comments = get_comments(		array(			'author_email'              => $email_address,			'number'                    => $number,			'paged'                     => $page,			'orderby'                   => 'comment_ID',			'order'                     => 'ASC',			'update_comment_meta_cache' => false,		)	); 	$comment_prop_to_export = array(		'comment_author'       => __( 'Comment Author' ),		'comment_author_email' => __( 'Comment Author Email' ),		'comment_author_url'   => __( 'Comment Author URL' ),		'comment_author_IP'    => __( 'Comment Author IP' ),		'comment_agent'        => __( 'Comment Author User Agent' ),		'comment_date'         => __( 'Comment Date' ),		'comment_content'      => __( 'Comment Content' ),		'comment_link'         => __( 'Comment URL' ),	); 	foreach ( (array) $comments as $comment ) {		$comment_data_to_export = array(); 		foreach ( $comment_prop_to_export as $key => $name ) {			$value = ''; 			switch ( $key ) {				case 'comment_author':				case 'comment_author_email':				case 'comment_author_url':				case 'comment_author_IP':				case 'comment_agent':				case 'comment_date':					$value = $comment->{$key};					break; 				case 'comment_content':					$value = get_comment_text( $comment->comment_ID );					break; 				case 'comment_link':					$value = get_comment_link( $comment->comment_ID );					$value = sprintf(						'<a href="%s" target="_blank">%s</a>',						esc_url( $value ),						esc_html( $value )					);					break;			} 			if ( ! empty( $value ) ) {				$comment_data_to_export[] = array(					'name'  => $name,					'value' => $value,				);			}		} 		$data_to_export[] = array(			'group_id'          => 'comments',			'group_label'       => __( 'Comments' ),			'group_description' => __( 'User&#8217;s comment data.' ),			'item_id'           => "comment-{$comment->comment_ID}",			'data'              => $comment_data_to_export,		);	} 	$done = count( $comments ) < $number; 	return array(		'data' => $data_to_export,

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 6.8.8 tag, from src/wp-includes/comment.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.