--- a/wp/wp-includes/revision.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/revision.php Wed Sep 21 18:19:35 2022 +0200
@@ -227,6 +227,8 @@
*
* @since 2.6.0
*
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
* @param int $post_id The post ID.
* @param int $user_id Optional The post author ID.
* @return WP_Post|false The autosaved data or false on failure or when no autosave exists.
@@ -329,7 +331,7 @@
$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;
}
@@ -369,12 +371,12 @@
return null;
}
- if ( OBJECT == $output ) {
+ if ( OBJECT === $output ) {
return $revision;
- } elseif ( ARRAY_A == $output ) {
+ } elseif ( ARRAY_A === $output ) {
$_revision = get_object_vars( $revision );
return $_revision;
- } elseif ( ARRAY_N == $output ) {
+ } elseif ( ARRAY_N === $output ) {
$_revision = array_values( get_object_vars( $revision ) );
return $_revision;
}
@@ -545,7 +547,7 @@
if ( true === $num ) {
$num = -1;
} else {
- $num = intval( $num );
+ $num = (int) $num;
}
if ( ! post_type_supports( $post->post_type, 'revisions' ) ) {
@@ -562,7 +564,24 @@
* @param int $num Number of revisions to store.
* @param WP_Post $post Post object.
*/
- return (int) apply_filters( 'wp_revisions_to_keep', $num, $post );
+ $num = apply_filters( 'wp_revisions_to_keep', $num, $post );
+
+ /**
+ * Filters the number of revisions to save for the given post by its post type.
+ *
+ * Overrides both the value of WP_POST_REVISIONS and the {@see 'wp_revisions_to_keep'} filter.
+ *
+ * The dynamic portion of the hook name, `$post->post_type`, refers to
+ * the post type slug.
+ *
+ * @since 5.8.0
+ *
+ * @param int $num Number of revisions to store.
+ * @param WP_Post $post Post object.
+ */
+ $num = apply_filters( "wp_{$post->post_type}_revisions_to_keep", $num, $post );
+
+ return (int) $num;
}
/**
@@ -676,12 +695,12 @@
return $value;
}
- $thumbnail_id = intval( $_REQUEST['_thumbnail_id'] );
+ $thumbnail_id = (int) $_REQUEST['_thumbnail_id'];
if ( $thumbnail_id <= 0 ) {
return '';
}
- return strval( $thumbnail_id );
+ return (string) $thumbnail_id;
}
/**