<!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>[24406] trunk: Heartbeat: rename some vars/args to make them more intuitive, don't set user_id on every request, see #23216</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/24406">24406</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-06-05 00:13:40 +0000 (Wed, 05 Jun 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Heartbeat: rename some vars/args to make them more intuitive, don't set user_id on every request, see <a href="http://core.trac.wordpress.org/ticket/23216">#23216</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesajaxactionsphp">trunk/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunkwpadminincludesmiscphp">trunk/wp-admin/includes/misc.php</a></li>
<li><a href="#trunkwpadminjsinlineeditpostjs">trunk/wp-admin/js/inline-edit-post.js</a></li>
<li><a href="#trunkwpincludesjsheartbeatjs">trunk/wp-includes/js/heartbeat.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ajax-actions.php (24405 => 24406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ajax-actions.php 2013-06-03 22:20:43 UTC (rev 24405)
+++ trunk/wp-admin/includes/ajax-actions.php    2013-06-05 00:13:40 UTC (rev 24406)
</span><span class="lines">@@ -13,10 +13,10 @@
</span><span class="cx">  $response = array();
</span><span class="cx"> 
</span><span class="cx">  // screen_id is the same as $current_screen->id and the JS global 'pagenow'
</span><del>-       if ( ! empty($_POST['screenid']) )
-               $screen_id = sanitize_key($_POST['screenid']);
</del><ins>+        if ( ! empty($_POST['screen_id']) )
+               $screen_id = sanitize_key($_POST['screen_id']);
</ins><span class="cx">   else
</span><del>-               $screen_id = 'site';
</del><ins>+                $screen_id = 'front';
</ins><span class="cx"> 
</span><span class="cx">  if ( ! empty($_POST['data']) ) {
</span><span class="cx">          $data = wp_unslash( (array) $_POST['data'] );
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx">  do_action( 'heartbeat_nopriv_tick', $response, $screen_id );
</span><span class="cx"> 
</span><span class="cx">  // send the current time according to the server
</span><del>-       $response['servertime'] = time();
</del><ins>+        $response['server_time'] = time();
</ins><span class="cx"> 
</span><span class="cx">  wp_send_json($response);
</span><span class="cx"> }
</span><span class="lines">@@ -2058,16 +2058,13 @@
</span><span class="cx">  $response = array();
</span><span class="cx"> 
</span><span class="cx">  // screen_id is the same as $current_screen->id and the JS global 'pagenow'
</span><del>-       if ( ! empty($_POST['screenid']) )
-               $screen_id = sanitize_key($_POST['screenid']);
</del><ins>+        if ( ! empty($_POST['screen_id']) )
+               $screen_id = sanitize_key($_POST['screen_id']);
</ins><span class="cx">   else
</span><del>-               $screen_id = 'site';
</del><ins>+                $screen_id = 'front';
</ins><span class="cx"> 
</span><span class="cx">  if ( ! empty($_POST['data']) ) {
</span><span class="cx">          $data = (array) $_POST['data'];
</span><del>-               // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..?
-               $user = wp_get_current_user();
-               $data['user_id'] = $user->exists() ? $user->ID : 0;
</del><span class="cx"> 
</span><span class="cx">          // todo: separate filters: 'heartbeat_[action]' so we call different callbacks only when there is data for them,
</span><span class="cx">          // or all callbacks listen to one filter and run when there is something for them in $data?
</span><span class="lines">@@ -2080,7 +2077,7 @@
</span><span class="cx">  do_action( 'heartbeat_tick', $response, $screen_id );
</span><span class="cx"> 
</span><span class="cx">  // send the current time acording to the server
</span><del>-       $response['servertime'] = time();
</del><ins>+        $response['server_time'] = time();
</ins><span class="cx"> 
</span><span class="cx">  wp_send_json($response);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesmiscphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/misc.php (24405 => 24406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/misc.php 2013-06-03 22:20:43 UTC (rev 24405)
+++ trunk/wp-admin/includes/misc.php    2013-06-05 00:13:40 UTC (rev 24406)
</span><span class="lines">@@ -569,8 +569,8 @@
</span><span class="cx"> function wp_check_locked_posts( $response, $data, $screen_id ) {
</span><span class="cx">  $checked = array();
</span><span class="cx"> 
</span><del>-       if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked', $data ) && is_array( $data['wp-check-locked'] ) ) {
-               foreach ( $data['wp-check-locked'] as $key ) {
</del><ins>+        if ( 'edit-post' == $screen_id && array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
+               foreach ( $data['wp-check-locked-posts'] as $key ) {
</ins><span class="cx">                   $post_id = (int) substr( $key, 5 );
</span><span class="cx"> 
</span><span class="cx">                  if ( current_user_can( 'edit_post', $post_id ) && ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
</span><span class="lines">@@ -585,7 +585,7 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  if ( ! empty( $checked ) )
</span><del>-               $response['wp-check-locked'] = $checked;
</del><ins>+                $response['wp-check-locked-posts'] = $checked;
</ins><span class="cx"> 
</span><span class="cx">  return $response;
</span><span class="cx"> }
</span><span class="lines">@@ -601,10 +601,10 @@
</span><span class="cx">          $received = $data['wp-refresh-post-lock'];
</span><span class="cx">          $send = array();
</span><span class="cx"> 
</span><del>-               if ( !$post_id = absint( $received['post_id'] ) )
</del><ins>+                if ( ! $post_id = absint( $received['post_id'] ) )
</ins><span class="cx">                   return $response;
</span><span class="cx"> 
</span><del>-               if ( !current_user_can('edit_post', $post_id) )
</del><ins>+                if ( ! current_user_can('edit_post', $post_id) )
</ins><span class="cx">                   return $response;
</span><span class="cx"> 
</span><span class="cx">          if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
</span></span></pre></div>
<a id="trunkwpadminjsinlineeditpostjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/inline-edit-post.js (24405 => 24406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/inline-edit-post.js    2013-06-03 22:20:43 UTC (rev 24405)
+++ trunk/wp-admin/js/inline-edit-post.js       2013-06-05 00:13:40 UTC (rev 24406)
</span><span class="lines">@@ -293,8 +293,8 @@
</span><span class="cx"> $( document ).ready( function(){ inlineEditPost.init(); } );
</span><span class="cx"> 
</span><span class="cx"> // Show/hide locks on posts
</span><del>-$( document ).on( 'heartbeat-tick.wp-check-locked', function( e, data ) {
-       var locked = data['wp-check-locked'] || {};
</del><ins>+$( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
+       var locked = data['wp-check-locked-posts'] || {};
</ins><span class="cx"> 
</span><span class="cx">  $('#the-list tr').each( function(i, el) {
</span><span class="cx">          var key = el.id, row = $(el), lock_data, avatar;
</span><span class="lines">@@ -315,7 +315,7 @@
</span><span class="cx">                  row.find('.column-title .locked-avatar').empty();
</span><span class="cx">          }
</span><span class="cx">  });
</span><del>-}).on( 'heartbeat-send.wp-check-locked', function( e, data ) {
</del><ins>+}).on( 'heartbeat-send.wp-check-locked-posts', function( e, data ) {
</ins><span class="cx">   var check = [];
</span><span class="cx"> 
</span><span class="cx">  $('#the-list tr').each( function(i, el) {
</span><span class="lines">@@ -324,7 +324,7 @@
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="cx">  if ( check.length )
</span><del>-               data['wp-check-locked'] = check;
</del><ins>+                data['wp-check-locked-posts'] = check;
</ins><span class="cx"> });
</span><span class="cx"> 
</span><span class="cx"> }(jQuery));
</span></span></pre></div>
<a id="trunkwpincludesjsheartbeatjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/heartbeat.js (24405 => 24406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/heartbeat.js        2013-06-03 22:20:43 UTC (rev 24405)
+++ trunk/wp-includes/js/heartbeat.js   2013-06-05 00:13:40 UTC (rev 24406)
</span><span class="lines">@@ -11,7 +11,7 @@
</span><span class="cx">                  running,
</span><span class="cx">                  beat,
</span><span class="cx">                  nonce,
</span><del>-                       screenid = typeof pagenow != 'undefined' ? pagenow : '',
</del><ins>+                        screenId = typeof pagenow != 'undefined' ? pagenow : '',
</ins><span class="cx">                   url = typeof ajaxurl != 'undefined' ? ajaxurl : '',
</span><span class="cx">                  settings,
</span><span class="cx">                  tick = 0,
</span><span class="lines">@@ -42,17 +42,17 @@
</span><span class="cx"> 
</span><span class="cx">                  interval = settings.interval || 15; // default interval
</span><span class="cx">                  delete settings.interval;
</span><del>-                       // The interval can be from 5 to 60 sec.
-                       if ( interval < 5 )
-                               interval = 5;
</del><ins>+                        // The interval can be from 15 to 60 sec. and can be set temporarily to 5 sec.
+                       if ( interval < 15 )
+                               interval = 15;
</ins><span class="cx">                   else if ( interval > 60 )
</span><span class="cx">                          interval = 60;
</span><span class="cx"> 
</span><span class="cx">                  interval = interval * 1000;
</span><span class="cx"> 
</span><del>-                       // 'screenid' can be added from settings on the front-end where the JS global 'pagenow' is not set
-                       screenid = screenid || settings.screenid || 'site';
-                       delete settings.screenid;
</del><ins>+                        // 'screenId' can be added from settings on the front-end where the JS global 'pagenow' is not set
+                       screenId = screenId || settings.screenId || 'front';
+                       delete settings.screenId;
</ins><span class="cx"> 
</span><span class="cx">                  // Add or overwrite public vars
</span><span class="cx">                  $.extend( this, settings );
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx">                  return false;
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               // Set error state and fire an event if XHR errors or timeout
</del><ins>+                // Set error state and fire an event on XHR errors or timeout
</ins><span class="cx">           function errorstate( error ) {
</span><span class="cx">                  var trigger;
</span><span class="cx"> 
</span><span class="lines">@@ -148,7 +148,7 @@
</span><span class="cx">                  send.interval = interval / 1000;
</span><span class="cx">                  send._nonce = nonce;
</span><span class="cx">                  send.action = 'heartbeat';
</span><del>-                       send.screenid = screenid;
</del><ins>+                        send.screen_id = screenId;
</ins><span class="cx">                   send.has_focus = hasFocus;
</span><span class="cx"> 
</span><span class="cx">                  connecting = true;
</span></span></pre>
</div>
</div>

</body>
</html>