<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[13376] trunk/wp-includes/wp-db.php: More wpdb cleanups, see #12362</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13376">13376</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-24 18:58:52 +0000 (Wed, 24 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>More wpdb cleanups, see <a href="http://trac.wordpress.org/ticket/12362">#12362</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludeswpdbphp">trunk/wp-includes/wp-db.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludeswpdbphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/wp-db.php (13375 => 13376)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/wp-db.php        2010-02-24 18:52:54 UTC (rev 13375)
+++ trunk/wp-includes/wp-db.php        2010-02-24 18:58:52 UTC (rev 13376)
</span><span class="lines">@@ -568,10 +568,10 @@
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;prefix = $this-&gt;get_blog_prefix( $this-&gt;blogid );
</span><span class="cx"> 
</span><del>-                foreach ( (array) $this-&gt;tables( 'blog' ) as $table =&gt; $prefixed_table )
</del><ins>+                foreach ( $this-&gt;tables( 'blog' ) as $table =&gt; $prefixed_table )
</ins><span class="cx">                         $this-&gt;$table = $prefixed_table;
</span><span class="cx"> 
</span><del>-                foreach ( (array) $this-&gt;tables( 'old' ) as $table =&gt; $prefixed_table )
</del><ins>+                foreach ( $this-&gt;tables( 'old' ) as $table =&gt; $prefixed_table )
</ins><span class="cx">                         $this-&gt;$table = $prefixed_table;
</span><span class="cx"> 
</span><span class="cx">                 return $old_prefix;
</span><span class="lines">@@ -630,6 +630,14 @@
</span><span class="cx">          * override the WordPress users and usersmeta tables that would otherwise
</span><span class="cx">          * be determined by the prefix.
</span><span class="cx">          *
</span><ins>+         * The scope argument can take one of the following:
+         *
+         * 'all' - returns 'all' and 'global' tables. No old tables are returned.
+         * 'global' - returns the global tables for the installation, returning multisite tables only if running multisite.
+         * 'ms_global' - returns the multisite global tables, regardless if current installation is multisite.
+         * 'blog' - returns the blog-level tables for the queried blog.
+         * 'old' - returns tables which are deprecated.
+         *
</ins><span class="cx">          * @since 3.0.0
</span><span class="cx">          * @uses wpdb::$tables
</span><span class="cx">          * @uses wpdb::$old_tables
</span><span class="lines">@@ -637,38 +645,36 @@
</span><span class="cx">          * @uses wpdb::$ms_global_tables
</span><span class="cx">          * @uses is_multisite()
</span><span class="cx">          *
</span><del>-         * @param string $scope Can be all, global, ms_global, blog, or old tables. Defaults to all.
-         *         'all' returns 'all' and 'global' tables. No old tables are returned.
-         *         'global' returns the global tables for the installation, returning multisite tables only if running multisite.
-         *         'ms_global' returns the multisite global tables, regardless if current installation is multisite.
-         *         'blog' returns the blog-level tables for the queried blog.
-         *         'old' returns tables which are deprecated.
-         * @param bool $prefix Whether to include table prefixes. Default true. If blog
</del><ins>+         * @param string $scope Optional. Can be all, global, ms_global, blog, or old tables. Defaults to all.
+         * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog
</ins><span class="cx">          *         prefix is requested, then the custom users and usermeta tables will be mapped.
</span><del>-         * @param int $blog_id The blog_id to prefix. Defaults to wpdb::blogid. Used only when prefix is requested.
</del><ins>+         * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb::blogid. Used only when prefix is requested.
</ins><span class="cx">          * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
</span><span class="cx">          */
</span><span class="cx">         function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
</span><span class="cx">                 switch ( $scope ) {
</span><del>-                        case 'old' :
-                                $tables = $this-&gt;old_tables;
</del><ins>+                        case 'all' :
+                                $tables = array_merge( $this-&gt;global_tables, $this-&gt;tables );
+                                if ( is_multisite() )
+                                        $tables = array_merge( $tables, $this-&gt;ms_global_tables );
</ins><span class="cx">                                 break;
</span><del>-                        case 'blog' :
-                                $tables = $this-&gt;tables;
-                                break;
-                        case 'ms_global' :
-                                $tables = $this-&gt;ms_global_tables;
-                                break;
</del><span class="cx">                         case 'global' :
</span><span class="cx">                                 $tables = $this-&gt;global_tables;
</span><span class="cx">                                 if ( is_multisite() )
</span><span class="cx">                                         $tables = array_merge( $tables, $this-&gt;ms_global_tables );
</span><span class="cx">                                 break;
</span><del>-                        case 'all' :
-                                $tables = array_merge( $this-&gt;global_tables, $this-&gt;tables );
-                                if ( is_multisite() )
-                                        $tables = array_merge( $tables, $this-&gt;ms_global_tables );
</del><ins>+                        case 'ms_global' :
+                                $tables = $this-&gt;ms_global_tables;
</ins><span class="cx">                                 break;
</span><ins>+                        case 'blog' :
+                                $tables = $this-&gt;tables;
+                                break;
+                        case 'old' :
+                                $tables = $this-&gt;old_tables;
+                                break;
+                        default :
+                                return array();
+                                break;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ( $prefix ) {
</span><span class="lines">@@ -723,9 +729,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Weak escape
</del><ins>+         * Weak escape, using addslashes()
</ins><span class="cx">          *
</span><del>-         * @uses addslashes()
</del><ins>+         * @see addslashes()
</ins><span class="cx">          * @since {@internal Version Unknown}}
</span><span class="cx">          * @access private
</span><span class="cx">          *
</span><span class="lines">@@ -737,10 +743,10 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Real escape
</del><ins>+         * Real escape, using mysql_real_escape_string() or addslashes()
</ins><span class="cx">          *
</span><del>-         * @uses mysql_real_escape_string()
-         * @uses addslashes()
</del><ins>+         * @see mysql_real_escape_string()
+         * @see addslashes()
</ins><span class="cx">          * @since 2.8
</span><span class="cx">          * @access private
</span><span class="cx">          *
</span><span class="lines">@@ -786,7 +792,7 @@
</span><span class="cx">          * Works on arrays.
</span><span class="cx">          *
</span><span class="cx">          * @since 0.71
</span><del>-         * @param  string|array $data to escape
</del><ins>+         * @param string|array $data to escape
</ins><span class="cx">          * @return string|array escaped as query safe string
</span><span class="cx">          */
</span><span class="cx">         function escape( $data ) {
</span><span class="lines">@@ -809,7 +815,7 @@
</span><span class="cx">          *
</span><span class="cx">          * @uses wpdb::_real_escape()
</span><span class="cx">          * @since 2.3.0
</span><del>-         * @param  string $string to escape
</del><ins>+         * @param string $string to escape
</ins><span class="cx">          * @return void
</span><span class="cx">          */
</span><span class="cx">         function escape_by_ref( &amp;$string ) {
</span><span class="lines">@@ -1456,7 +1462,6 @@
</span><span class="cx">          * @see   wpdb::db_version()
</span><span class="cx">          *
</span><span class="cx">          * @param string $db_cap the feature
</span><del>-         * @param false|string|resource $dbh_or_table. Not implemented.
</del><span class="cx">          * @return bool
</span><span class="cx">          */
</span><span class="cx">         function has_cap( $db_cap ) {
</span><span class="lines">@@ -1489,16 +1494,15 @@
</span><span class="cx">                 foreach ( $trace as $call ) {
</span><span class="cx">                         if ( isset( $call['class'] ) &amp;&amp; __CLASS__ == $call['class'] )
</span><span class="cx">                                 continue; // Filter out wpdb calls.
</span><ins>+                        $caller[] = isset( $call['class'] ) ? &quot;{$call['class']}-&gt;{$call['function']}&quot; : $call['function'];
</ins><span class="cx">                 }
</span><del>-                $caller = join( ', ', $caller );
</del><span class="cx"> 
</span><del>-                return $caller;
</del><ins>+                return join( ', ', $caller );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * The database version number.
</span><span class="cx">          *
</span><del>-         * @param false|string|resource $dbh_or_table. Not implemented.
</del><span class="cx">          * @return false|string false on failure, version number on success
</span><span class="cx">          */
</span><span class="cx">         function db_version() {
</span></span></pre>
</div>
</div>

</body>
</html>