Make WordPress Core


Ignore:
Timestamp:
02/22/2023 08:47:38 PM (2 years ago)
Author:
johnbillion
Message:

Revisions: Remove an unnecessary call to _doing_it_wrong() and corresponding new text string from the implementation of the new wp_save_post_revision_revisions_before_deletion filter.

While the guard condition was technically correct, it's not practical or necessary to provide this protection for every use of every filter, and it adds unnecessary burden to translators to provide translations for strings that will likely not be seen.

Follow up to [55254].

Fixes #57320

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/revisions.php

    r55254 r55406  
    929929        );
    930930    }
    931 
    932     /**
    933      * Tests that wp_save_post_revision() ignores an invalid return value
    934      * from the 'wp_save_post_revision_revisions_before_deletion' filter
    935      * and throws _doing_it_wrong().
    936      *
    937      * @ticket 57320
    938      *
    939      * @covers ::wp_save_post_revision
    940      *
    941      * @expectedIncorrectUsage wp_save_post_revision
    942      */
    943     public function test_wp_save_post_revision_should_ignore_invalid_revisions_before_deletion_filter() {
    944         $post_id = self::factory()->post->create( array( 'post_title' => 'Test 57320' ) );
    945 
    946         add_filter(
    947             'wp_revisions_to_keep',
    948             static function() {
    949                 return 1;
    950             }
    951         );
    952 
    953         add_filter( 'wp_save_post_revision_revisions_before_deletion', '__return_null' );
    954 
    955         for ( $update = 1; $update < 4; ++$update ) {
    956             wp_update_post(
    957                 array(
    958                     'ID'         => $post_id,
    959                     'post_title' => 'Test 57320 Update ' . $update,
    960                 )
    961             );
    962         }
    963 
    964         $actual = wp_get_post_revisions( $post_id );
    965 
    966         $this->assertCount(
    967             1,
    968             $actual,
    969             'There should only be one revision.'
    970         );
    971 
    972         $first = reset( $actual );
    973 
    974         $this->assertSame(
    975             'Test 57320 Update 3',
    976             $first->post_title,
    977             'The title of the first revision was incorrect.'
    978         );
    979     }
    980931}
Note: See TracChangeset for help on using the changeset viewer.