<!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>[25669] trunk/src: Replace use of global `$user_ID` in favor of `get_current_user_id()`.</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/25669">25669</a></dd>
<dt>Author</dt> <dd>ocean90</dd>
<dt>Date</dt> <dd>2013-10-02 21:09:52 +0000 (Wed, 02 Oct 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Replace use of global `$user_ID` in favor of `get_current_user_id()`. fixes <a href="http://core.trac.wordpress.org/ticket/25372">#25372</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminincludespostphp">trunk/src/wp-admin/includes/post.php</a></li>
<li><a href="#trunksrcwpincludespostphp">trunk/src/wp-includes/post.php</a></li>
<li><a href="#trunksrcwpincludesqueryphp">trunk/src/wp-includes/query.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/ajax-actions.php (25668 => 25669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/ajax-actions.php 2013-10-02 21:04:36 UTC (rev 25668)
+++ trunk/src/wp-admin/includes/ajax-actions.php 2013-10-02 21:09:52 UTC (rev 25669)
</span><span class="lines">@@ -1372,7 +1372,7 @@
</span><span class="cx"> $data['excerpt'] = $post['post_excerpt'];
</span><span class="cx">
</span><span class="cx"> // rename
</span><del>- $data['user_ID'] = $GLOBALS['user_ID'];
</del><ins>+ $data['user_ID'] = get_current_user_id();
</ins><span class="cx">
</span><span class="cx"> if ( isset($data['post_parent']) )
</span><span class="cx"> $data['parent_id'] = $data['post_parent'];
</span></span></pre></div>
<a id="trunksrcwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/post.php (25668 => 25669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/post.php 2013-10-02 21:04:36 UTC (rev 25668)
+++ trunk/src/wp-admin/includes/post.php 2013-10-02 21:09:52 UTC (rev 25669)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> if ( isset($post_data['trackback_url']) )
</span><span class="cx"> $post_data['to_ping'] = $post_data['trackback_url'];
</span><span class="cx">
</span><del>- $post_data['user_ID'] = $GLOBALS['user_ID'];
</del><ins>+ $post_data['user_ID'] = get_current_user_id();
</ins><span class="cx">
</span><span class="cx"> if (!empty ( $post_data['post_author_override'] ) ) {
</span><span class="cx"> $post_data['post_author'] = (int) $post_data['post_author_override'];
</span><span class="lines">@@ -266,7 +266,7 @@
</span><span class="cx">
</span><span class="cx"> add_meta( $post_ID );
</span><span class="cx">
</span><del>- update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
</del><ins>+ update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
</ins><span class="cx">
</span><span class="cx"> wp_update_post( $post_data );
</span><span class="cx">
</span><span class="lines">@@ -538,8 +538,6 @@
</span><span class="cx"> * @return unknown
</span><span class="cx"> */
</span><span class="cx"> function wp_write_post() {
</span><del>- global $user_ID;
-
</del><span class="cx"> if ( isset($_POST['post_type']) )
</span><span class="cx"> $ptype = get_post_type_object($_POST['post_type']);
</span><span class="cx"> else
</span></span></pre></div>
<a id="trunksrcwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/post.php (25668 => 25669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/post.php 2013-10-02 21:04:36 UTC (rev 25668)
+++ trunk/src/wp-includes/post.php 2013-10-02 21:09:52 UTC (rev 25669)
</span><span class="lines">@@ -2655,7 +2655,6 @@
</span><span class="cx"> * setting the value for 'comment_status' key.
</span><span class="cx"> *
</span><span class="cx"> * @global wpdb $wpdb WordPress database abstraction object.
</span><del>- * @global int $user_ID
</del><span class="cx"> *
</span><span class="cx"> * @since 1.0.0
</span><span class="cx"> *
</span><span class="lines">@@ -2666,7 +2665,7 @@
</span><span class="cx"> * be updated. Default 0.
</span><span class="cx"> * @type string 'post_status' The post status. Default 'draft'.
</span><span class="cx"> * @type string 'post_type' The post type. Default 'post'.
</span><del>- * @type int 'post_author' The ID of the user who added the post. Default $user_ID, the current user ID.
</del><ins>+ * @type int 'post_author' The ID of the user who added the post. Default the current user ID.
</ins><span class="cx"> * @type bool 'ping_status' Whether the post can accept pings. Default value of 'default_ping_status' option.
</span><span class="cx"> * @type int 'post_parent' Set this for the post it belongs to, if any. Default 0.
</span><span class="cx"> * @type int 'menu_order' The order it is displayed. Default 0.
</span><span class="lines">@@ -2682,9 +2681,11 @@
</span><span class="cx"> * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
</span><span class="cx"> */
</span><span class="cx"> function wp_insert_post( $postarr, $wp_error = false ) {
</span><del>- global $wpdb, $user_ID;
</del><ins>+ global $wpdb;
</ins><span class="cx">
</span><del>- $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
</del><ins>+ $user_id = get_current_user_id();
+
+ $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_id,
</ins><span class="cx"> 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
</span><span class="cx"> 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '',
</span><span class="cx"> 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0,
</span><span class="lines">@@ -2749,7 +2750,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ( empty($post_author) )
</span><del>- $post_author = $user_ID;
</del><ins>+ $post_author = $user_id;
</ins><span class="cx">
</span><span class="cx"> // Don't allow contributors to set the post slug for pending review posts
</span><span class="cx"> if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) )
</span><span class="lines">@@ -3943,7 +3944,6 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 2.0.0
</span><span class="cx"> * @uses $wpdb
</span><del>- * @uses $user_ID
</del><span class="cx"> * @uses do_action() Calls 'edit_attachment' on $post_ID if this is an update.
</span><span class="cx"> * @uses do_action() Calls 'add_attachment' on $post_ID if this is not an update.
</span><span class="cx"> *
</span><span class="lines">@@ -3953,9 +3953,11 @@
</span><span class="cx"> * @return int Attachment ID.
</span><span class="cx"> */
</span><span class="cx"> function wp_insert_attachment($object, $file = false, $parent = 0) {
</span><del>- global $wpdb, $user_ID;
</del><ins>+ global $wpdb;
</ins><span class="cx">
</span><del>- $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
</del><ins>+ $user_id = get_current_user_id();
+
+ $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_id,
</ins><span class="cx"> 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'post_title' => '',
</span><span class="cx"> 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '',
</span><span class="cx"> 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
</span><span class="lines">@@ -3972,7 +3974,7 @@
</span><span class="cx"> extract($object, EXTR_SKIP);
</span><span class="cx">
</span><span class="cx"> if ( empty($post_author) )
</span><del>- $post_author = $user_ID;
</del><ins>+ $post_author = $user_id;
</ins><span class="cx">
</span><span class="cx"> $post_type = 'attachment';
</span><span class="cx">
</span><span class="lines">@@ -4496,8 +4498,6 @@
</span><span class="cx"> *
</span><span class="cx"> * @since 2.2.0
</span><span class="cx"> *
</span><del>- * @uses $user_ID
- *
</del><span class="cx"> * @param string $post_type currently only supports 'post' or 'page'.
</span><span class="cx"> * @return string SQL code that can be added to a where clause.
</span><span class="cx"> */
</span><span class="lines">@@ -4518,7 +4518,7 @@
</span><span class="cx"> * @return string SQL WHERE code that can be added to a query.
</span><span class="cx"> */
</span><span class="cx"> function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
</span><del>- global $user_ID, $wpdb;
</del><ins>+ global $wpdb;
</ins><span class="cx">
</span><span class="cx"> // Private posts
</span><span class="cx"> $post_type_obj = get_post_type_object( $post_type );
</span><span class="lines">@@ -4548,7 +4548,7 @@
</span><span class="cx"> $sql .= " OR post_status = 'private'";
</span><span class="cx"> } elseif ( is_user_logged_in() ) {
</span><span class="cx"> // Users can view their own private posts.
</span><del>- $id = (int) $user_ID;
</del><ins>+ $id = get_current_user_id();
</ins><span class="cx"> if ( null === $post_author || ! $full ) {
</span><span class="cx"> $sql .= " OR post_status = 'private' AND post_author = $id";
</span><span class="cx"> } elseif ( $id == (int) $post_author ) {
</span></span></pre></div>
<a id="trunksrcwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/query.php (25668 => 25669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/query.php 2013-10-02 21:04:36 UTC (rev 25668)
+++ trunk/src/wp-includes/query.php 2013-10-02 21:09:52 UTC (rev 25669)
</span><span class="lines">@@ -2140,7 +2140,7 @@
</span><span class="cx"> * @return array List of posts.
</span><span class="cx"> */
</span><span class="cx"> function get_posts() {
</span><del>- global $wpdb, $user_ID;
</del><ins>+ global $wpdb;
</ins><span class="cx">
</span><span class="cx"> $this->parse_query();
</span><span class="cx">
</span><span class="lines">@@ -2713,18 +2713,20 @@
</span><span class="cx"> unset($p_status);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ $user_id = get_current_user_id();
+
</ins><span class="cx"> if ( !empty($e_status) ) {
</span><span class="cx"> $statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
</span><span class="cx"> }
</span><span class="cx"> if ( !empty($r_status) ) {
</span><span class="cx"> if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) )
</span><del>- $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))";
</del><ins>+ $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))";
</ins><span class="cx"> else
</span><span class="cx"> $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
</span><span class="cx"> }
</span><span class="cx"> if ( !empty($p_status) ) {
</span><span class="cx"> if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) )
</span><del>- $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))";
</del><ins>+ $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))";
</ins><span class="cx"> else
</span><span class="cx"> $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
</span><span class="cx"> }
</span><span class="lines">@@ -2757,7 +2759,7 @@
</span><span class="cx"> // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
</span><span class="cx"> $private_states = get_post_stati( array('private' => true) );
</span><span class="cx"> foreach ( (array) $private_states as $state )
</span><del>- $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'";
</del><ins>+ $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $where .= ')';
</span></span></pre>
</div>
</div>
</body>
</html>