<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[24397] trunk/wp-includes: Remove saving of post_format in autosave and revisions, fixes #24455</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/24397">24397</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-06-02 01:29:44 +0000 (Sun, 02 Jun 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove saving of post_format in autosave and revisions, fixes <a href="http://core.trac.wordpress.org/ticket/24455">#24455</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesjsautosavejs">trunk/wp-includes/js/autosave.js</a></li>
<li><a href="#trunkwpincludesrevisionphp">trunk/wp-includes/revision.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesjsautosavejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/autosave.js (24396 => 24397)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/autosave.js 2013-06-01 09:40:00 UTC (rev 24396)
+++ trunk/wp-includes/js/autosave.js    2013-06-02 01:29:44 UTC (rev 24397)
</span><span class="lines">@@ -304,7 +304,7 @@
</span><span class="cx"> (function($){
</span><span class="cx"> // Returns the data for saving in both localStorage and autosaves to the server
</span><span class="cx"> wp.autosave.getPostData = function() {
</span><del>-       var ed = typeof tinymce != 'undefined' ? tinymce.activeEditor : null, post_name, parent_id, post_format, cats = [],
</del><ins>+        var ed = typeof tinymce != 'undefined' ? tinymce.activeEditor : null, post_name, parent_id, cats = [],
</ins><span class="cx">           data = {
</span><span class="cx">                  action: 'autosave',
</span><span class="cx">                  autosave: true,
</span><span class="lines">@@ -363,13 +363,6 @@
</span><span class="cx">  if ( $('#auto_draft').val() == '1' )
</span><span class="cx">          data['auto_draft'] = '1';
</span><span class="cx"> 
</span><del>-       post_format = $('#post_format').val() || '';
-       data['post_format'] = post_format == 'standard' ? '' : post_format;
-
-       $('.post-formats-fields').find('input[name^="_format_"], textarea[name^="_format_"]').each( function(i, field) {
-               data[ field.name ] = field.value || '';
-       });
-
</del><span class="cx">   return data;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesrevisionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/revision.php (24396 => 24397)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/revision.php   2013-06-01 09:40:00 UTC (rev 24396)
+++ trunk/wp-includes/revision.php      2013-06-02 01:29:44 UTC (rev 24397)
</span><span class="lines">@@ -59,27 +59,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Determines which post meta fields are revisioned.
- *
- * @since 3.6
- * @access private
- *
- * @return array An array of meta keys that should be revisioned.
- */
-function _wp_post_revision_meta_keys() {
-       return array(
-               '_format_url',
-               '_format_link_url',
-               '_format_quote_source_url',
-               '_format_quote_source_name',
-               '_format_image',
-               '_format_gallery',
-               '_format_audio_embed',
-               '_format_video_embed',
-       );
-}
-
-/**
</del><span class="cx">  * Saves an already existing post as a post revision.
</span><span class="cx">  *
</span><span class="cx">  * Typically used immediately after post updates.
</span><span class="lines">@@ -129,19 +108,6 @@
</span><span class="cx">                                  break;
</span><span class="cx">                          }
</span><span class="cx">                  }
</span><del>-
-                       // Check whether revisioned meta fields have changed.
-                       foreach ( _wp_post_revision_meta_keys() as $meta_key ) {
-                               if ( get_post_meta( $post->ID, $meta_key, true ) != get_post_meta( $last_revision->ID, $meta_key, true ) ) {
-                                       $post_has_changed = true;
-                                       break;
-                               }
-                       }
-
-                       // Check whether the post format has changed
-                       if ( get_post_format( $post->ID ) != get_post_meta( $last_revision->ID, '_revision_post_format', true ) )
-                               $post_has_changed = true;
-
</del><span class="cx">                   //don't save revision if post unchanged
</span><span class="cx">                  if( ! $post_has_changed )
</span><span class="cx">                          return;
</span><span class="lines">@@ -274,21 +240,6 @@
</span><span class="cx">  if ( $revision_id )
</span><span class="cx">          do_action( '_wp_put_post_revision', $revision_id );
</span><span class="cx"> 
</span><del>-       // Save revisioned meta fields.
-       foreach ( _wp_post_revision_meta_keys() as $meta_key ) {
-               $meta_value = get_post_meta( $post_id, $meta_key, true );
-               if ( empty( $meta_value ) )
-                       continue;
-
-               // Use the underlying add_metadata vs add_post_meta to make sure
-               // metadata is added to the revision post and not its parent.
-               add_metadata( 'post', $revision_id, $meta_key, wp_slash( $meta_value ) );
-       }
-
-       // Save the post format
-       if ( $post_format = get_post_format( $post_id ) )
-               add_metadata( 'post', $revision_id, '_revision_post_format', $post_format );
-
</del><span class="cx">   return $revision_id;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -359,18 +310,6 @@
</span><span class="cx"> 
</span><span class="cx">  $update = wp_slash( $update ); //since data is from db
</span><span class="cx"> 
</span><del>-       // Restore revisioned meta fields.
-       foreach ( _wp_post_revision_meta_keys() as $meta_key ) {
-               $meta_value = get_post_meta( $revision['ID'], $meta_key, true );
-               if ( empty( $meta_value ) )
-                       $meta_value = '';
-               // Add slashes to data pulled from the db
-               update_post_meta( $update['ID'], $meta_key, wp_slash( $meta_value ) );
-       }
-
-       // Restore post format
-       set_post_format( $update['ID'], get_post_meta( $revision['ID'], '_revision_post_format', true ) );
-
</del><span class="cx">   $post_id = wp_update_post( $update );
</span><span class="cx">  if ( ! $post_id || is_wp_error( $post_id ) )
</span><span class="cx">          return $post_id;
</span><span class="lines">@@ -505,9 +444,6 @@
</span><span class="cx">  $post->post_title = $preview->post_title;
</span><span class="cx">  $post->post_excerpt = $preview->post_excerpt;
</span><span class="cx"> 
</span><del>-       add_filter( 'get_post_metadata', '_wp_preview_meta_filter', 10, 4 );
-       add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );
-
</del><span class="cx">   return $post;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -530,49 +466,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Filters post meta retrieval to get values from the actual autosave post,
- * and not its parent. Filters revisioned meta keys only.
- *
- * @since 3.6.0
- * @access private
- */
-function _wp_preview_meta_filter( $value, $object_id, $meta_key, $single ) {
-       $post = get_post();
-
-       if ( $post->ID != $object_id || ! in_array( $meta_key, _wp_post_revision_meta_keys() ) || 'revision' == $post->post_type )
-               return $value;
-
-       $preview = wp_get_post_autosave( $post->ID );
-       if ( ! is_object( $preview ) )
-               return $value;
-
-       return get_post_meta( $preview->ID, $meta_key, $single );
-}
-
-/**
- * Filters terms lookup to get the post format saved with the preview revision.
- *
- * @since 3.6.0
- * @access private
- */
-function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
-       $post = get_post();
-
-       if ( $post->ID != $post_id || 'post_format' != $taxonomy || 'revision' == $post->post_type )
-               return $terms;
-
-       if ( ! $preview = wp_get_post_autosave( $post->ID ) )
-               return $terms;
-
-       if ( $post_format = get_post_meta( $preview->ID, '_revision_post_format', true ) ) {
-               if ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $post_format ), 'post_format' ) )
-                       $terms = array( $term ); // Can only have one post format
-       }
-
-       return $terms;
-}
-
-/**
</del><span class="cx">  * Gets the post revision version.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.6.0
</span></span></pre>
</div>
</div>

</body>
</html>