mirror of
git://develop.git.wordpress.org/
synced 2025-04-04 12:12:41 +02:00
Revisions: Check and return errors for insertions to revisions.
Fixes #30009. Props rmccue, adamsilverstein, coreymckrill, whyisjake. git-svn-id: https://develop.svn.wordpress.org/trunk@51124 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9f9261f051
commit
1eb777209d
@ -331,7 +331,7 @@ function _wp_put_post_revision( $post = null, $autosave = false ) {
|
||||
$post = _wp_post_revision_data( $post, $autosave );
|
||||
$post = wp_slash( $post ); // Since data is from DB.
|
||||
|
||||
$revision_id = wp_insert_post( $post );
|
||||
$revision_id = wp_insert_post( $post, true );
|
||||
if ( is_wp_error( $revision_id ) ) {
|
||||
return $revision_id;
|
||||
}
|
||||
|
@ -635,4 +635,21 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
|
||||
);
|
||||
$this->assertSame( $expected, wp_revisions_to_keep( $post ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Verify that trying to create a revision with an invalid ID returns a WP_Error.
|
||||
*
|
||||
*
|
||||
* @ticket 30009
|
||||
*/
|
||||
public function test_wp_save_post_revision_error() {
|
||||
$post = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'ID' => PHP_INT_MAX,
|
||||
)
|
||||
);
|
||||
$revision = _wp_put_post_revision( $post );
|
||||
$this->assertTrue( is_wp_error( $revision ) );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user