Add tests for update_user_caches().

See #24635.
Built from https://develop.svn.wordpress.org/trunk@34918


git-svn-id: http://core.svn.wordpress.org/trunk@34883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-10-07 22:35:26 +00:00
parent 9daa848297
commit b0e0323337
5 changed files with 16 additions and 9 deletions

View File

@ -197,7 +197,7 @@ $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_
// Detect if there exists an autosave newer than the post and if that autosave is different than the post // Detect if there exists an autosave newer than the post and if that autosave is different than the post
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) { foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
$notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) ); $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
break; break;

View File

@ -1656,7 +1656,7 @@ function wp_create_post_autosave( $post_data ) {
// If the new autosave has the same content as the post, delete the autosave. // If the new autosave has the same content as the post, delete the autosave.
$post = get_post( $post_id ); $post = get_post( $post_id );
$autosave_is_different = false; $autosave_is_different = false;
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields() ) ) as $field ) { foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
$autosave_is_different = true; $autosave_is_different = true;
break; break;

View File

@ -54,7 +54,7 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
$return = array(); $return = array();
foreach ( _wp_post_revision_fields() as $field => $name ) { foreach ( _wp_post_revision_fields( $post ) as $field => $name ) {
/** /**
* Contextually filter a post revision field. * Contextually filter a post revision field.
* *

View File

@ -14,17 +14,22 @@
* an array whose keys are the post fields to be saved for post revisions. * an array whose keys are the post fields to be saved for post revisions.
* *
* @since 2.6.0 * @since 2.6.0
* @since 4.4.0 A `WP_Post` object can now be passed to the `$post` parameter.
* @access private * @access private
* *
* @staticvar array $fields * @staticvar array $fields
* *
* @param array $post Optional. A post array to be processed for insertion as a post revision. * @param array|WP_Post $post Optional. A post array, or a WP_Post object to be processed for insertion as a post revision.
* @param bool $autosave Optional. Is the revision an autosave? * @param bool $autosave Optional. Is the revision an autosave? Default false.
* @return array Post array ready to be inserted as a post revision or array of fields that can be versioned. * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
*/ */
function _wp_post_revision_fields( $post = null, $autosave = false ) { function _wp_post_revision_fields( $post = null, $autosave = false ) {
static $fields = null; static $fields = null;
if ( is_object( $post ) ) {
$post = get_post( $post, ARRAY_A );
}
if ( is_null( $fields ) ) { if ( is_null( $fields ) ) {
// Allow these to be versioned // Allow these to be versioned
$fields = array( $fields = array(
@ -43,11 +48,13 @@ function _wp_post_revision_fields( $post = null, $autosave = false ) {
* and 'post_author'. * and 'post_author'.
* *
* @since 2.6.0 * @since 2.6.0
* @since 4.4.0 The `$post` parameter was added.
* *
* @param array $fields List of fields to revision. Contains 'post_title', * @param array $fields List of fields to revision. Contains 'post_title',
* 'post_content', and 'post_excerpt' by default. * 'post_content', and 'post_excerpt' by default.
* @param array $post A post array being processed for insertion as a post revision.
*/ */
$fields = apply_filters( '_wp_post_revision_fields', $fields ); $fields = apply_filters( '_wp_post_revision_fields', $fields, $post );
// WP uses these internally either in versioning or elsewhere - they cannot be versioned // WP uses these internally either in versioning or elsewhere - they cannot be versioned
foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect ) foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect )
@ -127,7 +134,7 @@ function wp_save_post_revision( $post_id ) {
if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) { if ( isset( $last_revision ) && apply_filters( 'wp_save_post_revision_check_for_changes', $check_for_changes = true, $last_revision, $post ) ) {
$post_has_changed = false; $post_has_changed = false;
foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) {
if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) { if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) {
$post_has_changed = true; $post_has_changed = true;
break; break;
@ -333,7 +340,7 @@ function wp_restore_post_revision( $revision_id, $fields = null ) {
return $revision; return $revision;
if ( !is_array( $fields ) ) if ( !is_array( $fields ) )
$fields = array_keys( _wp_post_revision_fields() ); $fields = array_keys( _wp_post_revision_fields( $revision ) );
$update = array(); $update = array();
foreach ( array_intersect( array_keys( $revision ), $fields ) as $field ) { foreach ( array_intersect( array_keys( $revision ), $fields ) as $field ) {

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34916'; $wp_version = '4.4-alpha-34918';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.