WordPress.org

Make WordPress Core

Changeset 46426


Ignore:
Timestamp:
10/07/2019 08:27:20 PM (2 months ago)
Author:
johnbillion
Message:

Pings/Trackbacks: Avoid adding multiple _pingme and _encloseme meta entries to a post when it gets updated prior to pings being done.

Props rebasaurus, whyisjake

Fixes #48014

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r46353 r46426  
    68016801
    68026802    if ( get_option( 'default_pingback_flag' ) ) {
    6803         add_post_meta( $post_id, '_pingme', '1' );
    6804     }
    6805     add_post_meta( $post_id, '_encloseme', '1' );
     6803        add_post_meta( $post_id, '_pingme', '1', true );
     6804    }
     6805    add_post_meta( $post_id, '_encloseme', '1', true );
    68066806
    68076807    $to_ping = get_to_ping( $post_id );
  • trunk/tests/phpunit/tests/post.php

    r46318 r46426  
    14311431        self::assertEquals( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date_gmt ), 'The dates should be equal', 2 );
    14321432    }
     1433
     1434    /**
     1435     * @ticket 48014
     1436     */
     1437    public function test_updated_post_should_not_duplicate_enclosure_meta_fields() {
     1438        $post_id = self::factory()->post->create();
     1439
     1440        $encloseme_before = get_post_meta( $post_id, '_encloseme' );
     1441        $pingme_before    = get_post_meta( $post_id, '_pingme' );
     1442
     1443        $updated = wp_update_post( get_post( $post_id ), true );
     1444
     1445        $encloseme_after = get_post_meta( $post_id, '_encloseme' );
     1446        $pingme_after    = get_post_meta( $post_id, '_pingme' );
     1447
     1448        $this->assertSame( $post_id, $updated );
     1449
     1450        $this->assertCount( 1, $encloseme_before );
     1451        $this->assertCount( 1, $encloseme_after );
     1452
     1453        $this->assertCount( 1, $pingme_before );
     1454        $this->assertCount( 1, $pingme_after );
     1455    }
    14331456}
Note: See TracChangeset for help on using the changeset viewer.