<!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>[38275] trunk/src/wp-includes: Query: add a `protected` field, `$db`, (composition, as it were) to `WP_*_Query` classes to hold the value for the database abstraction, instead of importing the `global $wpdb` into every method that uses it.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/38275">38275</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/38275","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-08-18 18:20:55 +0000 (Thu, 18 Aug 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Query: add a `protected` field, `$db`, (composition, as it were) to `WP_*_Query` classes to hold the value for the database abstraction, instead of importing the `global $wpdb` into every method that uses it. Reduces the number of global imports by 32.
See <a href="https://core.trac.wordpress.org/ticket/37699">#37699</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpcommentqueryphp">trunk/src/wp-includes/class-wp-comment-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswpmetaqueryphp">trunk/src/wp-includes/class-wp-meta-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswpnetworkqueryphp">trunk/src/wp-includes/class-wp-network-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswpsitequeryphp">trunk/src/wp-includes/class-wp-site-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswptaxqueryphp">trunk/src/wp-includes/class-wp-tax-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswptermqueryphp">trunk/src/wp-includes/class-wp-term-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswpuserqueryphp">trunk/src/wp-includes/class-wp-user-query.php</a></li>
<li><a href="#trunksrcwpincludesclasswpuserphp">trunk/src/wp-includes/class-wp-user.php</a></li>
<li><a href="#trunksrcwpincludesclasswpxmlrpcserverphp">trunk/src/wp-includes/class-wp-xmlrpc-server.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpcommentqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-comment-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-comment-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-comment-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -142,6 +142,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Sets up the comment query, based on the query vars passed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -260,6 +267,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $query = '' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->query_var_defaults = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_email' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author_url' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -363,13 +372,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return int|array List of comments or number of found comments if `$count` argument is true.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_comments() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->parse_query();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse meta query
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -388,7 +393,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Reparse query vars, in case they were modified in a 'pre_get_comments' callback.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->meta_query->parse_query_vars( $this->query_vars );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->meta_query->queries ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $this->db->comments, 'comment_ID', $this );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // $args can include anything. Only use the args defined in the query_var_defaults to compute the key.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -480,12 +485,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_comment_ids() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Assemble clauses related to 'comment_approved'.
</span><span class="cx" style="display: block; padding: 0 10px"> $approved_clauses = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -514,7 +515,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> default :
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $status_clauses[] = $wpdb->prepare( "comment_approved = %s", $status );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $status_clauses[] = $this->db->prepare( "comment_approved = %s", $status );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -537,11 +538,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $include_unapproved as $unapproved_identifier ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Numeric values are assumed to be user ids.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $unapproved_identifier ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $approved_clauses[] = $this->db->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Otherwise we match against email addresses.
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $approved_clauses[] = $this->db->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -600,7 +601,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If no valid clauses were found, order by comment_date_gmt.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $orderby_array ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby_array[] = "$wpdb->comments.comment_date_gmt $order";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby_array[] = "{$this->db->comments}.comment_date_gmt $order";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // To ensure determinate sorting, always include a comment_ID clause.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -633,12 +634,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_ID_order = 'DESC';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby_array[] = "$wpdb->comments.comment_ID $comment_ID_order";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby_array[] = "{$this->db->comments}.comment_ID $comment_ID_order";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby = implode( ', ', $orderby_array );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "$wpdb->comments.comment_date_gmt $order";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "{$this->db->comments}.comment_date_gmt $order";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $number = absint( $this->query_vars['number'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -655,22 +656,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['count'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = 'COUNT(*)';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = "$wpdb->comments.comment_ID";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $fields = "{$this->db->comments}.comment_ID";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = absint( $this->query_vars['post_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $post_id ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['post_id'] = $this->db->prepare( 'comment_post_ID = %d', $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse comment IDs for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['comment__in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['comment__in'] = "$wpdb->comments.comment_ID IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['comment__in'] = "{$this->db->comments}.comment_ID IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse comment IDs for a NOT IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['comment__not_in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['comment__not_in'] = "$wpdb->comments.comment_ID NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['comment__not_in'] = "{$this->db->comments}.comment_ID NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse comment parent IDs for an IN clause.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -694,15 +695,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $this->query_vars['author_email'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['author_email'] = $wpdb->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['author_email'] = $this->db->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $this->query_vars['author_url'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['author_url'] = $wpdb->prepare( 'comment_author_url = %s', $this->query_vars['author_url'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['author_url'] = $this->db->prepare( 'comment_author_url = %s', $this->query_vars['author_url'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $this->query_vars['karma'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['karma'] = $wpdb->prepare( 'comment_karma = %d', $this->query_vars['karma'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['karma'] = $this->db->prepare( 'comment_karma = %d', $this->query_vars['karma'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Filtering by comment_type: 'type', 'type__in', 'type__not_in'.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -733,7 +734,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comment_types[ $operator ][] = $wpdb->prepare( '%s', $type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comment_types[ $operator ][] = $this->db->prepare( '%s', $type );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -750,13 +751,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $parent ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['parent'] = $wpdb->prepare( 'comment_parent = %d', $parent );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['parent'] = $this->db->prepare( 'comment_parent = %d', $parent );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['user_id'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['where']['user_id'] = 'user_id IN (' . implode( ',', array_map( 'absint', $this->query_vars['user_id'] ) ) . ')';
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( '' !== $this->query_vars['user_id'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['user_id'] = $wpdb->prepare( 'user_id = %d', $this->query_vars['user_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['user_id'] = $this->db->prepare( 'user_id = %d', $this->query_vars['user_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Falsy search strings are ignored.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -780,7 +781,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $post_fields as $field_name => $field_value ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // $field_value may be an array.
</span><span class="cx" style="display: block; padding: 0 10px"> $esses = array_fill( 0, count( (array) $field_value ), '%s' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where'][ $field_name ] = $this->db->prepare( " {$this->db->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -801,7 +802,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $join_posts_table = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $esses = array_fill( 0, count( $q_values ), '%s' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ")", $q_values );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where'][ $field_name ] = $this->db->prepare( " {$this->db->posts}.{$field_name} IN (" . implode( ',', $esses ) . ")", $q_values );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -830,7 +831,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $join = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $join_posts_table ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $join .= "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $join .= "JOIN {$this->db->posts} ON {$this->db->posts}.ID = {$this->db->comments}.comment_post_ID";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->meta_query_clauses ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -840,7 +841,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $this->meta_query_clauses['where'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->query_vars['count'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $groupby = "{$wpdb->comments}.comment_ID";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $groupby = "{$this->db->comments}.comment_ID";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -889,7 +890,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['select'] = "SELECT $found_rows $fields";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['from'] = "FROM $wpdb->comments $join";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['from'] = "FROM {$this->db->comments} $join";
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['groupby'] = $groupby;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['orderby'] = $orderby;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['limits'] = $limits;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -897,9 +898,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['count'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return intval( $wpdb->get_var( $this->request ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return intval( $this->db->get_var( $this->request ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comment_ids = $wpdb->get_col( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comment_ids = $this->db->get_col( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> return array_map( 'intval', $comment_ids );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -910,12 +911,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function set_found_comments() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the query used to retrieve found comment count.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -927,7 +924,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->found_comments = (int) $wpdb->get_var( $found_comments_query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->found_comments = (int) $this->db->get_var( $found_comments_query );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -943,8 +940,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function fill_descendants( $comments ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $levels = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 0 => wp_list_pluck( $comments, 'comment_ID' ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -996,7 +991,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $uncached_parent_ids ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $where = 'WHERE ' . $_where . ' AND comment_parent IN (' . implode( ',', array_map( 'intval', $uncached_parent_ids ) ) . ')';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $level_comments = $wpdb->get_results( "SELECT $wpdb->comments.comment_ID, $wpdb->comments.comment_parent {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} ORDER BY comment_date_gmt ASC, comment_ID ASC" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $level_comments = $this->db->get_results( "SELECT {$this->db->comments}.comment_ID, {$this->db->comments}.comment_parent {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} ORDER BY comment_date_gmt ASC, comment_ID ASC" );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Cache parent-child relationships.
</span><span class="cx" style="display: block; padding: 0 10px"> $parent_map = array_fill_keys( $uncached_parent_ids, array() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1067,20 +1062,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $string
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $cols
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_search_sql( $string, $cols ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . $this->db->esc_like( $string ) . '%';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . $wpdb->esc_like( $string ) . '%';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $searches = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $cols as $col ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $searches[] = $wpdb->prepare( "$col LIKE %s", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $searches[] = $this->db->prepare( "$col LIKE %s", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return ' AND (' . implode(' OR ', $searches) . ')';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1092,14 +1083,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $orderby Alias for the field to order by.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Value to used in the ORDER clause. False otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_orderby( $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $allowed_keys = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_agent',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_approved',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1131,19 +1118,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $parsed = false;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "$wpdb->commentmeta.meta_value";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "{$this->db->commentmeta}.meta_value";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $orderby == 'meta_value_num' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "$wpdb->commentmeta.meta_value+0";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "{$this->db->commentmeta}.meta_value+0";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $orderby == 'comment__in' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "FIELD( {$this->db->comments}.comment_ID, $comment__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( in_array( $orderby, $allowed_keys ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $meta_query_clauses[ $orderby ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_clause = $meta_query_clauses[ $orderby ];
</span><span class="cx" style="display: block; padding: 0 10px"> $parsed = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "$wpdb->comments.$orderby";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "{$this->db->comments}.$orderby";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpmetaqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-meta-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-meta-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-meta-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,6 +106,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> protected $has_or_relation = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.2.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,8 +144,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $meta_query = false ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !$meta_query )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
+ if ( ! $meta_query ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $meta_query['relation'] ) && strtoupper( $meta_query['relation'] ) == 'OR' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->relation = 'OR';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -484,8 +494,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $clause Query clause, passed by reference.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $parent_query Parent query array.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $clause_key Optional. The array key used to name the clause in the original `$meta_query`
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -498,8 +506,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $sql_chunks = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'where' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'join' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -537,7 +543,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'NOT EXISTS' === $meta_compare ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $join .= " LEFT JOIN $this->meta_table";
</span><span class="cx" style="display: block; padding: 0 10px"> $join .= $i ? " AS $alias" : '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $join .= $wpdb->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $join .= $this->db->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // All other JOIN clauses.
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -581,7 +587,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'NOT EXISTS' === $meta_compare ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $sql_chunks['where'][] = $alias . '.' . $this->meta_id_column . ' IS NULL';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sql_chunks['where'][] = $wpdb->prepare( "$alias.meta_key = %s", trim( $clause['key'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sql_chunks['where'][] = $this->db->prepare( "$alias.meta_key = %s", trim( $clause['key'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -601,25 +607,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case 'IN' :
</span><span class="cx" style="display: block; padding: 0 10px"> case 'NOT IN' :
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_compare_string = '(' . substr( str_repeat( ',%s', count( $meta_value ) ), 1 ) . ')';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where = $wpdb->prepare( $meta_compare_string, $meta_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where = $this->db->prepare( $meta_compare_string, $meta_value );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'BETWEEN' :
</span><span class="cx" style="display: block; padding: 0 10px"> case 'NOT BETWEEN' :
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_value = array_slice( $meta_value, 0, 2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where = $wpdb->prepare( '%s AND %s', $meta_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where = $this->db->prepare( '%s AND %s', $meta_value );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> case 'LIKE' :
</span><span class="cx" style="display: block; padding: 0 10px"> case 'NOT LIKE' :
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $meta_value = '%' . $wpdb->esc_like( $meta_value ) . '%';
- $where = $wpdb->prepare( '%s', $meta_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $meta_value = '%' . $this->db->esc_like( $meta_value ) . '%';
+ $where = $this->db->prepare( '%s', $meta_value );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // EXISTS with a value is interpreted as '='.
</span><span class="cx" style="display: block; padding: 0 10px"> case 'EXISTS' :
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_compare = '=';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where = $wpdb->prepare( '%s', $meta_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where = $this->db->prepare( '%s', $meta_value );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // 'value' is ignored for NOT EXISTS.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -628,7 +634,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> default :
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where = $wpdb->prepare( '%s', $meta_value );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where = $this->db->prepare( '%s', $meta_value );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpnetworkqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-network-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-network-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-network-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,6 +87,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $max_num_pages = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Sets up the network query, based on the query vars passed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -124,6 +131,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $query = '' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->query_var_defaults = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'network__in' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'network__not_in' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -290,8 +299,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return int|array A single count of network IDs if a count query. An array of network IDs if a full query.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_network_ids() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $order = $this->parse_order( $this->query_vars['order'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Disable ORDER BY with 'none', an empty array, or boolean false.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,7 +339,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $orderby = implode( ', ', $orderby_array );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $orderby = "$wpdb->site.id $order";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $orderby = "{$this->db->site}.id $order";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $number = absint( $this->query_vars['number'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -349,52 +356,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['count'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = 'COUNT(*)';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = "$wpdb->site.id";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $fields = "{$this->db->site}.id";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse network IDs for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['network__in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['network__in'] = "$wpdb->site.id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['network__in'] = "{$this->db->site}.id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse network IDs for a NOT IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['network__not_in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['network__not_in'] = "$wpdb->site.id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['network__not_in'] = "{$this->db->site}.id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['domain'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['domain'] = $wpdb->prepare( "$wpdb->site.domain = %s", $this->query_vars['domain'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['domain'] = $this->db->prepare( "{$this->db->site}.domain = %s", $this->query_vars['domain'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse network domain for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['domain__in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['domain__in'] = "$wpdb->site.domain IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['domain__in'] = "{$this->db->site}.domain IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['domain__in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse network domain for a NOT IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['domain__not_in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['domain__not_in'] = "$wpdb->site.domain NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__not_in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['domain__not_in'] = "{$this->db->site}.domain NOT IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['domain__not_in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['path'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['path'] = $wpdb->prepare( "$wpdb->site.path = %s", $this->query_vars['path'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['path'] = $this->db->prepare( "{$this->db->site}.path = %s", $this->query_vars['path'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse network path for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['path__in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['path__in'] = "$wpdb->site.path IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['path__in'] = "{$this->db->site}.path IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['path__in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse network path for a NOT IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['path__not_in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['path__not_in'] = "$wpdb->site.path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['path__not_in'] = "{$this->db->site}.path NOT IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Falsey search strings are ignored.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( strlen( $this->query_vars['search'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['where']['search'] = $this->get_search_sql(
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_vars['search'],
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array( "$wpdb->site.domain", "$wpdb->site.path" )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( "{$this->db->site}.domain", "{$this->db->site}.path" )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -439,7 +446,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['select'] = "SELECT $found_rows $fields";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['from'] = "FROM $wpdb->site $join";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['from'] = "FROM {$this->db->site} $join";
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['groupby'] = $groupby;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['orderby'] = $orderby;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['limits'] = $limits;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -447,10 +454,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['count'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return intval( $wpdb->get_var( $this->request ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return intval( $this->db->get_var( $this->request ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $network_ids = $wpdb->get_col( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network_ids = $this->db->get_col( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return array_map( 'intval', $network_ids );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -461,12 +468,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function set_found_networks() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the query used to retrieve found network count.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -478,7 +481,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $found_networks_query = apply_filters( 'found_networks_query', 'SELECT FOUND_ROWS()', $this );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->found_networks = (int) $wpdb->get_var( $found_networks_query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->found_networks = (int) $this->db->get_var( $found_networks_query );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -488,21 +491,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $string Search string.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $columns Columns to search.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string Search SQL.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_search_sql( $string, $columns ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . $this->db->esc_like( $string ) . '%';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . $wpdb->esc_like( $string ) . '%';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $searches = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $columns as $column ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $searches[] = $wpdb->prepare( "$column LIKE %s", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $searches[] = $this->db->prepare( "$column LIKE %s", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return '(' . implode( ' OR ', $searches ) . ')';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -514,14 +513,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $orderby Alias for the field to order by.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Value to used in the ORDER clause. False otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_orderby( $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $allowed_keys = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id',
</span><span class="cx" style="display: block; padding: 0 10px"> 'domain',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -531,12 +526,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $parsed = false;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $orderby == 'network__in' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "FIELD( {$wpdb->site}.id, $network__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "FIELD( {$this->db->site}.id, $network__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( $orderby == 'domain_length' || $orderby == 'path_length' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $field = substr( $orderby, 0, -7 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "CHAR_LENGTH($wpdb->site.$field)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "CHAR_LENGTH({$this->db->site}.$field)";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( in_array( $orderby, $allowed_keys ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "$wpdb->site.$orderby";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "{$this->db->site}.$orderby";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $parsed;
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpsitequeryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-site-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-site-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-site-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,6 +96,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $max_num_pages = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Sets up the site query, based on the query vars passed.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,6 +154,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $query = '' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->query_var_defaults = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'fields' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,13 +334,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return int|array A single count of site IDs if a count query. An array of site IDs if a full query.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_site_ids() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $order = $this->parse_order( $this->query_vars['order'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Disable ORDER BY with 'none', an empty array, or boolean false.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -395,7 +400,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site IDs for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> $site_id = absint( $this->query_vars['ID'] );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $site_id ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['ID'] = $wpdb->prepare( 'blog_id = %d', $site_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['ID'] = $this->db->prepare( 'blog_id = %d', $site_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site IDs for an IN clause.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -411,7 +416,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $network_id = absint( $this->query_vars['network_id'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $network_id ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['network_id'] = $wpdb->prepare( 'site_id = %d', $network_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['network_id'] = $this->db->prepare( 'site_id = %d', $network_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site network IDs for an IN clause.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -425,56 +430,56 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['domain'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['domain'] = $wpdb->prepare( 'domain = %s', $this->query_vars['domain'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['domain'] = $this->db->prepare( 'domain = %s', $this->query_vars['domain'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site domain for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['domain__in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['domain__in'] = "domain IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['domain__in'] = "domain IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['domain__in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site domain for a NOT IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['domain__not_in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['domain__not_in'] = "domain NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__not_in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['domain__not_in'] = "domain NOT IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['domain__not_in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->query_vars['path'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['path'] = $wpdb->prepare( 'path = %s', $this->query_vars['path'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['path'] = $this->db->prepare( 'path = %s', $this->query_vars['path'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site path for an IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['path__in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['path__in'] = "path IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['path__in'] = "path IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['path__in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse site path for a NOT IN clause.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $this->query_vars['path__not_in'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['path__not_in'] = "path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['path__not_in'] = "path NOT IN ( '" . implode( "', '", $this->db->_escape( $this->query_vars['path__not_in'] ) ) . "' )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $this->query_vars['archived'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $archived = absint( $this->query_vars['archived'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['archived'] = $wpdb->prepare( "archived = %d ", $archived );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['archived'] = $this->db->prepare( "archived = %d ", $archived );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $this->query_vars['mature'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $mature = absint( $this->query_vars['mature'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['mature'] = $wpdb->prepare( "mature = %d ", $mature );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['mature'] = $this->db->prepare( "mature = %d ", $mature );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $this->query_vars['spam'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $spam = absint( $this->query_vars['spam'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['spam'] = $wpdb->prepare( "spam = %d ", $spam );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['spam'] = $this->db->prepare( "spam = %d ", $spam );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $this->query_vars['deleted'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $deleted = absint( $this->query_vars['deleted'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['deleted'] = $wpdb->prepare( "deleted = %d ", $deleted );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['deleted'] = $this->db->prepare( "deleted = %d ", $deleted );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_numeric( $this->query_vars['public'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $public = absint( $this->query_vars['public'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['public'] = $wpdb->prepare( "public = %d ", $public );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['public'] = $this->db->prepare( "public = %d ", $public );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Falsey search strings are ignored.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -550,7 +555,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['select'] = "SELECT $found_rows $fields";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['from'] = "FROM $wpdb->blogs $join";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['from'] = "FROM {$this->db->blogs} $join";
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['groupby'] = $groupby;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['orderby'] = $orderby;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['limits'] = $limits;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -558,10 +563,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['count'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return intval( $wpdb->get_var( $this->request ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return intval( $this->db->get_var( $this->request ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_ids = $wpdb->get_col( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_ids = $this->db->get_col( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return array_map( 'intval', $site_ids );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -572,12 +577,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function set_found_sites() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the query used to retrieve found site count.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -589,7 +590,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->found_sites = (int) $wpdb->get_var( $found_sites_query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->found_sites = (int) $this->db->get_var( $found_sites_query );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -599,24 +600,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $string Search string.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $columns Columns to search.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string Search SQL.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_search_sql( $string, $columns ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( false !== strpos( $string, '*' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . implode( '%', array_map( array( $wpdb, 'esc_like' ), explode( '*', $string ) ) ) . '%';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . implode( '%', array_map( array( $this->db, 'esc_like' ), explode( '*', $string ) ) ) . '%';
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . $wpdb->esc_like( $string ) . '%';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . $this->db->esc_like( $string ) . '%';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $searches = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $columns as $column ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $searches[] = $wpdb->prepare( "$column LIKE %s", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $searches[] = $this->db->prepare( "$column LIKE %s", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return '(' . implode( ' OR ', $searches ) . ')';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -628,24 +625,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $orderby Alias for the field to order by.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Value to used in the ORDER clause. False otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_orderby( $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $parsed = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch ( $orderby ) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'site__in':
</span><span class="cx" style="display: block; padding: 0 10px"> $site__in = implode( ',', array_map( 'absint', $this->query_vars['site__in'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "FIELD( {$wpdb->blogs}.blog_id, $site__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "FIELD( {$this->db->blogs}.blog_id, $site__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'network__in':
</span><span class="cx" style="display: block; padding: 0 10px"> $network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parsed = "FIELD( {$wpdb->blogs}.site_id, $network__in )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parsed = "FIELD( {$this->db->blogs}.site_id, $network__in )";
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'domain':
</span><span class="cx" style="display: block; padding: 0 10px"> case 'last_updated':
</span></span></pre></div>
<a id="trunksrcwpincludesclasswptaxqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-tax-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-tax-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-tax-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -92,6 +92,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $primary_id_column;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,6 +126,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $tax_query ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $tax_query['relation'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->relation = $this->sanitize_relation( $tax_query['relation'] );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -387,8 +396,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb The WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $clause Query clause, passed by reference.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $parent_query Parent query array.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -399,8 +406,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_sql_for_clause( &$clause, $parent_query ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $sql = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'where' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'join' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -432,7 +437,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $alias = $this->find_compatible_table_alias( $clause, $parent_query );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false === $alias ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $i = count( $this->table_aliases );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $alias = $i ? 'tt' . $i : $wpdb->term_relationships;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $alias = $i ? 'tt' . $i : $this->db->term_relationships;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Store the alias as part of a flat array to build future iterators.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->table_aliases[] = $alias;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -440,7 +445,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Store the alias with this clause, so later siblings can use it.
</span><span class="cx" style="display: block; padding: 0 10px"> $clause['alias'] = $alias;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $join .= " LEFT JOIN $wpdb->term_relationships";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $join .= " LEFT JOIN {$this->db->term_relationships}";
</ins><span class="cx" style="display: block; padding: 0 10px"> $join .= $i ? " AS $alias" : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $join .= " ON ($this->primary_table.$this->primary_id_column = $alias.object_id)";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -458,7 +463,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $where = "$this->primary_table.$this->primary_id_column NOT IN (
</span><span class="cx" style="display: block; padding: 0 10px"> SELECT object_id
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM $wpdb->term_relationships
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->term_relationships}
</ins><span class="cx" style="display: block; padding: 0 10px"> WHERE term_taxonomy_id IN ($terms)
</span><span class="cx" style="display: block; padding: 0 10px"> )";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -474,20 +479,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $where = "(
</span><span class="cx" style="display: block; padding: 0 10px"> SELECT COUNT(1)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM $wpdb->term_relationships
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->term_relationships}
</ins><span class="cx" style="display: block; padding: 0 10px"> WHERE term_taxonomy_id IN ($terms)
</span><span class="cx" style="display: block; padding: 0 10px"> AND object_id = $this->primary_table.$this->primary_id_column
</span><span class="cx" style="display: block; padding: 0 10px"> ) = $num_terms";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'NOT EXISTS' === $operator || 'EXISTS' === $operator ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $where = $wpdb->prepare( "$operator (
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $where = $this->db->prepare( "$operator (
</ins><span class="cx" style="display: block; padding: 0 10px"> SELECT 1
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM $wpdb->term_relationships
- INNER JOIN $wpdb->term_taxonomy
- ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
- WHERE $wpdb->term_taxonomy.taxonomy = %s
- AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->term_relationships}
+ INNER JOIN {$this->db->term_taxonomy}
+ ON {$this->db->term_taxonomy}.term_taxonomy_id = {$this->db->term_relationships}.term_taxonomy_id
+ WHERE {$this->db->term_taxonomy}.taxonomy = %s
+ AND {$this->db->term_relationships}.object_id = $this->primary_table.$this->primary_id_column
</ins><span class="cx" style="display: block; padding: 0 10px"> )", $clause['taxonomy'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -597,15 +602,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb The WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $query The single query. Passed by reference.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id',
</span><span class="cx" style="display: block; padding: 0 10px"> * or 'term_id'. Default 'term_id'.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function transform_query( &$query, $resulting_field ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $query['terms'] ) )
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -628,27 +629,27 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = implode( ",", $query['terms'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $wpdb->get_col( "
- SELECT $wpdb->term_taxonomy.$resulting_field
- FROM $wpdb->term_taxonomy
- INNER JOIN $wpdb->terms USING (term_id)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = $this->db->get_col( "
+ SELECT {$this->db->term_taxonomy}.$resulting_field
+ FROM {$this->db->term_taxonomy}
+ INNER JOIN {$this->db->terms} USING (term_id)
</ins><span class="cx" style="display: block; padding: 0 10px"> WHERE taxonomy = '{$query['taxonomy']}'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- AND $wpdb->terms.{$query['field']} IN ($terms)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ AND {$this->db->terms}.{$query['field']} IN ($terms)
</ins><span class="cx" style="display: block; padding: 0 10px"> " );
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'term_taxonomy_id':
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = implode( ',', array_map( 'intval', $query['terms'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $wpdb->get_col( "
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = $this->db->get_col( "
</ins><span class="cx" style="display: block; padding: 0 10px"> SELECT $resulting_field
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM $wpdb->term_taxonomy
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->term_taxonomy}
</ins><span class="cx" style="display: block; padding: 0 10px"> WHERE term_taxonomy_id IN ($terms)
</span><span class="cx" style="display: block; padding: 0 10px"> " );
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><span class="cx" style="display: block; padding: 0 10px"> $terms = implode( ',', array_map( 'intval', $query['terms'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $wpdb->get_col( "
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = $this->db->get_col( "
</ins><span class="cx" style="display: block; padding: 0 10px"> SELECT $resulting_field
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM $wpdb->term_taxonomy
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->term_taxonomy}
</ins><span class="cx" style="display: block; padding: 0 10px"> WHERE taxonomy = '{$query['taxonomy']}'
</span><span class="cx" style="display: block; padding: 0 10px"> AND term_id IN ($terms)
</span><span class="cx" style="display: block; padding: 0 10px"> " );
</span></span></pre></div>
<a id="trunksrcwpincludesclasswptermqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-term-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-term-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-term-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,6 +87,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $terms;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Sets up the term query, based on the query vars passed.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,6 +179,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $query = '' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->query_var_defaults = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'taxonomy' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> 'orderby' => 'name',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -293,13 +302,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_terms() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->parse_query( $this->query_vars );
</span><span class="cx" style="display: block; padding: 0 10px"> $args = $this->query_vars;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -486,16 +491,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $tt_ids = implode( ',', array_map( 'intval', $args['term_taxonomy_id'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})";
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['term_taxonomy_id'] = $wpdb->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['term_taxonomy_id'] = $this->db->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $args['name__like'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['name__like'] = $wpdb->prepare( "t.name LIKE %s", '%' . $wpdb->esc_like( $args['name__like'] ) . '%' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['name__like'] = $this->db->prepare( "t.name LIKE %s", '%' . $this->db->esc_like( $args['name__like'] ) . '%' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $args['description__like'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['where']['description__like'] = $wpdb->prepare( "tt.description LIKE %s", '%' . $wpdb->esc_like( $args['description__like'] ) . '%' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['where']['description__like'] = $this->db->prepare( "tt.description LIKE %s", '%' . $this->db->esc_like( $args['description__like'] ) . '%' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' !== $parent ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -591,7 +596,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $join .= " INNER JOIN {$this->db->term_taxonomy} AS tt ON t.term_id = tt.term_id";
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $where = implode( ' AND ', $this->sql_clauses['where'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -621,7 +626,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['select'] = "SELECT $distinct $fields";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->sql_clauses['from'] = "FROM $wpdb->terms AS t $join";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sql_clauses['from'] = "FROM {$this->db->terms} AS t $join";
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sql_clauses['limits'] = $limits;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -646,10 +651,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'count' == $_fields ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $wpdb->get_var( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->db->get_var( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $terms = $wpdb->get_results( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $terms = $this->db->get_results( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 'all' == $_fields ) {
</span><span class="cx" style="display: block; padding: 0 10px"> update_term_cache( $terms );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -753,8 +758,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $orderby_raw Alias for the field to order by.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Value to used in the ORDER clause. False otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -894,16 +897,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.6.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $string
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_search_sql( $string ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = '%' . $this->db->esc_like( $string ) . '%';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = '%' . $wpdb->esc_like( $string ) . '%';
-
- return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->db->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpuserqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-user-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-user-query.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-user-query.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,6 +71,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $query_limit;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * PHP5 constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,6 +85,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param null|string|array $query Optional. The query variables.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $query = null ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $query ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->prepare_query( $query );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,7 +143,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> * @global int $blog_id
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array $query {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -198,8 +206,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function prepare_query( $query = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $this->query_vars ) || ! empty( $query ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_limit = null;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_vars = $this->fill_query_vars( $query );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -228,19 +234,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_fields = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $qv['fields'] as $field ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $field = 'ID' === $field ? 'ID' : sanitize_key( $field );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_fields[] = "$wpdb->users.$field";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_fields[] = "{$this->db->users}.$field";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_fields = implode( ',', $this->query_fields );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'all' == $qv['fields'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_fields = "$wpdb->users.*";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_fields = "{$this->db->users}.*";
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_fields = "$wpdb->users.ID";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_fields = "{$this->db->users}.ID";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $qv['count_total'] ) && $qv['count_total'] )
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_from = "FROM $wpdb->users";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_from = "FROM {$this->db->users}";
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->query_where = "WHERE 1=1";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Parse and sanitize 'include', for use by 'orderby' as well as 'include' below.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -263,11 +269,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $post_types as &$post_type ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type = $wpdb->prepare( '%s', $post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type = $this->db->prepare( '%s', $post_type );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $posts_table = $wpdb->get_blog_prefix( $blog_id ) . 'posts';
- $this->query_where .= " AND $wpdb->users.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( " . join( ", ", $post_types ) . " ) )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $posts_table = $this->db->get_blog_prefix( $blog_id ) . 'posts';
+ $this->query_where .= " AND {$this->db->users}.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( " . join( ", ", $post_types ) . " ) )";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Meta query.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,7 +282,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $who_query = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'key' => $this->db->get_blog_prefix( $blog_id ) . 'user_level',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'value' => 0,
</span><span class="cx" style="display: block; padding: 0 10px"> 'compare' => '!=',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -323,7 +329,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $roles ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $roles as $role ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $roles_clauses[] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'key' => $this->db->get_blog_prefix( $blog_id ) . 'capabilities',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'value' => '"' . $role . '"',
</span><span class="cx" style="display: block; padding: 0 10px"> 'compare' => 'LIKE',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -336,7 +342,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $role__in ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $role__in as $role ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $role__in_clauses[] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'key' => $this->db->get_blog_prefix( $blog_id ) . 'capabilities',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'value' => '"' . $role . '"',
</span><span class="cx" style="display: block; padding: 0 10px"> 'compare' => 'LIKE',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -349,7 +355,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $role__not_in ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $role__not_in as $role ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $role__not_in_clauses[] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'key' => $this->db->get_blog_prefix( $blog_id ) . 'capabilities',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'value' => '"' . $role . '"',
</span><span class="cx" style="display: block; padding: 0 10px"> 'compare' => 'NOT LIKE',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -361,7 +367,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // If there are no specific roles named, make sure the user is a member of the site.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $role_queries ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $role_queries[] = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'key' => $this->db->get_blog_prefix( $blog_id ) . 'capabilities',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'compare' => 'EXISTS',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -383,7 +389,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->meta_query->queries ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $clauses = $this->meta_query->get_sql( 'user', $wpdb->users, 'ID', $this );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $clauses = $this->meta_query->get_sql( 'user', $this->db->users, 'ID', $this );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->query_from .= $clauses['join'];
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_where .= $clauses['where'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -441,9 +447,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // limit
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $qv['number'] ) && $qv['number'] > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $qv['offset'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_limit = $this->db->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_limit = $wpdb->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_limit = $this->db->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -499,10 +505,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $include ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Sanitized earlier.
</span><span class="cx" style="display: block; padding: 0 10px"> $ids = implode( ',', $include );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_where .= " AND $wpdb->users.ID IN ($ids)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_where .= " AND {$this->db->users}.ID IN ($ids)";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! empty( $qv['exclude'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query_where .= " AND {$this->db->users}.ID NOT IN ($ids)";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Date queries are allowed for the user_registered field.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -530,20 +536,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Execute the query, with the current variables.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function query() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $qv =& $this->query_vars;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->results = $wpdb->get_results( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->results = $this->db->get_results( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->results = $wpdb->get_col( $this->request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->results = $this->db->get_col( $this->request );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -551,15 +553,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $qv['count_total'] ) && $qv['count_total'] )
- $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $qv['count_total'] ) && $qv['count_total'] ) {
+ $this->total_users = $this->db->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( !$this->results )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $this->results ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'all_with_meta' == $qv['fields'] ) {
</span><span class="cx" style="display: block; padding: 0 10px"> cache_users( $this->results );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -611,8 +613,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $string
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $cols
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -620,18 +620,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_search_sql( $string, $cols, $wild = false ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $searches = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : '';
</span><span class="cx" style="display: block; padding: 0 10px"> $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $like = $leading_wild . $this->db->esc_like( $string ) . $trailing_wild;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $cols as $col ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'ID' == $col ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $searches[] = $wpdb->prepare( "$col = %s", $string );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $searches[] = $this->db->prepare( "$col = %s", $string );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $searches[] = $wpdb->prepare( "$col LIKE %s", $like );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $searches[] = $this->db->prepare( "$col LIKE %s", $like );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -668,14 +666,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $orderby Alias for the field to order by.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string Value to used in the ORDER clause, if `$orderby` is valid.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_orderby( $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $meta_query_clauses = $this->meta_query->get_clauses();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_orderby = '';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -690,22 +684,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $where = get_posts_by_author_sql( 'post' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query_from .= " LEFT OUTER JOIN (
</span><span class="cx" style="display: block; padding: 0 10px"> SELECT post_author, COUNT(*) as post_count
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM $wpdb->posts
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->posts}
</ins><span class="cx" style="display: block; padding: 0 10px"> $where
</span><span class="cx" style="display: block; padding: 0 10px"> GROUP BY post_author
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ) p ON ({$wpdb->users}.ID = p.post_author)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) p ON ({$this->db->users}.ID = p.post_author)
</ins><span class="cx" style="display: block; padding: 0 10px"> ";
</span><span class="cx" style="display: block; padding: 0 10px"> $_orderby = 'post_count';
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'ID' == $orderby || 'id' == $orderby ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $_orderby = 'ID';
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'meta_value' == $orderby || $this->get( 'meta_key' ) == $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_orderby = "$wpdb->usermeta.meta_value";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_orderby = "{$this->db->usermeta}.meta_value";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'meta_value_num' == $orderby ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_orderby = "$wpdb->usermeta.meta_value+0";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_orderby = "{$this->db->usermeta}.meta_value+0";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $include = wp_parse_id_list( $this->query_vars['include'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $include_sql = implode( ',', $include );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_orderby = "FIELD( $wpdb->users.ID, $include_sql )";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_orderby = "FIELD( {$this->db->users}.ID, $include_sql )";
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( isset( $meta_query_clauses[ $orderby ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_clause = $meta_query_clauses[ $orderby ];
</span><span class="cx" style="display: block; padding: 0 10px"> $_orderby = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) );
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpuserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-user.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-user.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,6 +102,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> private static $back_compat_keys;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieves the userdata and passes it to WP_User::init().
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,15 +116,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. User's username
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $blog_id Optional Site ID, defaults to current site.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $id = 0, $name = '', $blog_id = '' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( self::$back_compat_keys ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $prefix = $GLOBALS['wpdb']->prefix;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $prefix = $this->db->prefix;
</ins><span class="cx" style="display: block; padding: 0 10px"> self::$back_compat_keys = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_firstname' => 'first_name',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_lastname' => 'last_name',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -232,10 +239,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$user = $wpdb->get_row( $wpdb->prepare(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value
- ) ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "SELECT * FROM {$wpdb->users} WHERE $db_field = %s", $value
+ ) ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> update_user_caches( $user );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $user;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -442,18 +449,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $cap_key Optional capability key
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function _init_caps( $cap_key = '' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
- if ( empty($cap_key) )
- $this->cap_key = $wpdb->get_blog_prefix() . 'capabilities';
- else
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $cap_key ) ) {
+ $this->cap_key = $this->db->get_blog_prefix() . 'capabilities';
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->cap_key = $cap_key;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->caps = get_user_meta( $this->ID, $this->cap_key, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_array( $this->caps ) )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -631,13 +634,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function update_user_level_from_caps() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( $this->ID, $this->db->get_blog_prefix() . 'user_level', $this->user_level );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -679,14 +679,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function remove_all_caps() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->caps = array();
</span><span class="cx" style="display: block; padding: 0 10px"> delete_user_meta( $this->ID, $this->cap_key );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_user_meta( $this->ID, $this->db->get_blog_prefix() . 'user_level' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->get_role_caps();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -772,16 +769,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $blog_id Optional. Site ID, defaults to current site.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function for_blog( $blog_id = '' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
- if ( ! empty( $blog_id ) )
- $cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
- else
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $blog_id ) ) {
+ $cap_key = $this->db->get_blog_prefix( $blog_id ) . 'capabilities';
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px"> $cap_key = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->_init_caps( $cap_key );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpxmlrpcserverphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-xmlrpc-server.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-xmlrpc-server.php 2016-08-18 03:47:55 UTC (rev 38274)
+++ trunk/src/wp-includes/class-wp-xmlrpc-server.php 2016-08-18 18:20:55 UTC (rev 38275)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -54,6 +54,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> protected $auth_failed = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0
+ * @access protected
+ * @var wpdb
+ */
+ protected $db;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Registers all of the XMLRPC methods that XMLRPC server understands.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Sets up server and method property. Passes XMLRPC
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,6 +70,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->db = $GLOBALS['wpdb'];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->methods = array(
</span><span class="cx" style="display: block; padding: 0 10px"> // WordPress API
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2882,8 +2891,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $args {
</span><span class="cx" style="display: block; padding: 0 10px"> * Method arguments. Note: arguments must be ordered as documented.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2894,8 +2901,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array|IXR_Error
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function wp_getPageList( $args ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->escape( $args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $username = $args[1];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2911,14 +2916,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'xmlrpc_call', 'wp.getPageList' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Get list of pages ids and titles
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $page_list = $wpdb->get_results("
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $page_list = $this->db->get_results("
</ins><span class="cx" style="display: block; padding: 0 10px"> SELECT ID page_id,
</span><span class="cx" style="display: block; padding: 0 10px"> post_title page_title,
</span><span class="cx" style="display: block; padding: 0 10px"> post_parent page_parent_id,
</span><span class="cx" style="display: block; padding: 0 10px"> post_date_gmt,
</span><span class="cx" style="display: block; padding: 0 10px"> post_date,
</span><span class="cx" style="display: block; padding: 0 10px"> post_status
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- FROM {$wpdb->posts}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ FROM {$this->db->posts}
</ins><span class="cx" style="display: block; padding: 0 10px"> WHERE post_type = 'page'
</span><span class="cx" style="display: block; padding: 0 10px"> ORDER BY ID
</span><span class="cx" style="display: block; padding: 0 10px"> ");
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5130,20 +5135,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $post_ID Post ID.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $post_content Post Content for attachment.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function attach_uploads( $post_ID, $post_content ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> // find any unattached files
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachments = $this->db->get_results( "SELECT ID, guid FROM {$this->db->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $attachments ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $attachments as $file ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false )
- $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) {
+ $this->db->update( $this->db->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5763,8 +5765,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param array $args {
</span><span class="cx" style="display: block; padding: 0 10px"> * Method arguments. Note: arguments must be ordered as documented.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5776,8 +5776,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array|IXR_Error
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mw_newMediaObject( $args ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> $username = $this->escape( $args[1] );
</span><span class="cx" style="display: block; padding: 0 10px"> $password = $this->escape( $args[2] );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $args[3];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6102,14 +6100,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param int $post_ID
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array|IXR_Error
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mt_getTrackbackPings( $post_ID ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'xmlrpc_call', 'mt.getTrackbackPings' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6118,7 +6112,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$actual_post )
</span><span class="cx" style="display: block; padding: 0 10px"> return new IXR_Error(404, __('Sorry, no such post.'));
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comments = $this->db->get_results( $this->db->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$this->db->comments} WHERE comment_post_ID = %d", $post_ID) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$comments )
</span><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6192,7 +6186,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
</del><span class="cx" style="display: block; padding: 0 10px"> * @global string $wp_version
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $args {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6204,7 +6197,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string|IXR_Error
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function pingback_ping( $args ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb, $wp_version;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ global $wp_version;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'xmlrpc_call', 'pingback.ping' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6258,8 +6251,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( is_string($urltest['fragment']) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // ...or a string #title, a little more complicated
</span><span class="cx" style="display: block; padding: 0 10px"> $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
- if (! ($post_ID = $wpdb->get_var($sql)) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sql = $this->db->prepare("SELECT ID FROM {$this->db->posts} WHERE post_title RLIKE %s", $title );
+ if (! ($post_ID = $this->db->get_var($sql)) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // returning unknown error '0' is better than die()ing
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->pingback_error( 0, '' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6283,7 +6276,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Let's check that the remote site didn't already pingback this entry
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->db->get_results( $this->db->prepare("SELECT * FROM {$this->db->comments} WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // very stupid, but gives time to the 'from' server to publish !
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6408,14 +6401,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @global wpdb $wpdb WordPress database abstraction object.
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @param string $url
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array|IXR_Error
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function pingback_extensions_getPingbacks( $url ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
-
</del><span class="cx" style="display: block; padding: 0 10px"> /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6434,7 +6423,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->pingback_error( 32, __('The specified target URL does not exist.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $comments = $this->db->get_results( $this->db->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$this->db->comments} WHERE comment_post_ID = %d", $post_ID) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !$comments )
</span><span class="cx" style="display: block; padding: 0 10px"> return array();
</span></span></pre>
</div>
</div>
</body>
</html>