[wp-trac] [WordPress Trac] #43442: Add tools for anonymizing of commenters

WordPress Trac noreply at wordpress.org
Tue Apr 17 11:39:20 UTC 2018


#43442: Add tools for anonymizing of commenters
------------------------------------------+---------------------
 Reporter:  azaozz                        |       Owner:  (none)
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  5.0
Component:  General                       |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  gdpr has-patch needs-testing  |     Focuses:
------------------------------------------+---------------------

Comment (by birgire):

 Three approaches come to mind regarding how we can update each comment in
 {{{wp_comments_personal_data_eraser()}}}:

 a. Use {{{wp_update_comment()}}}.
 b. Use {{{wp_update_comment()}}} with {{{wp_defer_comment_counting()}}}
 for better performance.
 c. Use {{{$wpdb->update()}}}, I would suggest this instead of
 {{{$wpdb->query()}}}.

 I did some timing and query counting over three runs for each approach,
 with 500 comments:

 {{{
 a) wp_update_comment()
 ------------------
 1. time: 1.627704
    #qs:  2501
 2. time: 1.661613
    #qs:  2501
 3. time: 1.607060
    #qs:  2501

 b) wp_update_comment() + defer counting
 ------------------
 1. time: 0.992301
    #qs:  1004
 2. time: 0.928880
    #qs:  1004
 3. time: 0.952708
    #qs:  1004

 c) $wpdb->update()
 ------------------
 1. time: 0.358650
    #qs:  501
 2. time: 0.348916
    #qs:  501
 3. time: 0.334349
    #qs:  501

 }}}

 As expected c) is the fastest with lowest number of queries.


 Here's the test setup:


 {{{
 global $wpdb;
 $count = 500;
 $post_id = self::factory()->post->create();
 $args = array(
         'comment_post_ID'      => $post_id,
         'comment_author'       => 'Comment Author',
         'comment_author_email' => 'personal at local.host',
         'comment_author_url'   => 'https://local.host/',
         'comment_author_IP'    => '192.168.0.1',
         'comment_date'         => '2018-03-28 20:05:00',
         'comment_agent'        => 'SOME_AGENT',
         'comment_content'      => 'Comment',
 );
 self::factory()->comment->create_many( $count, $args );

 $wpdb->timer_start();
 $query_count = $wpdb->num_queries;
 wp_comments_personal_data_eraser( $args['comment_author_email'] );

 printf( 'time: %f' . PHP_EOL, $wpdb->timer_stop() );
 printf( '#qs: %d' . PHP_EOL, $wpdb->num_queries - $query_count );

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43442#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list