<!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>[13209] trunk: Assume WP_DEBUG is defined in wpdb.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13209">13209</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-02-19 01:03:58 +0000 (Fri, 19 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Assume WP_DEBUG is defined in wpdb. Remove unnecessary constant() calls. Ensure DB_COLLATE defined as empty string doesn't override default Multisite collation. fixes <a href="http://trac.wordpress.org/ticket/12041">#12041</a>, see <a href="http://trac.wordpress.org/ticket/11644">#11644</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmsphp">trunk/wp-admin/includes/ms.php</a></li>
<li><a href="#trunkwpadminincludesupgradephp">trunk/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunkwpadminrevisionphp">trunk/wp-admin/revision.php</a></li>
<li><a href="#trunkwpincludesmsfunctionsphp">trunk/wp-includes/ms-functions.php</a></li>
<li><a href="#trunkwpincludesmsloadphp">trunk/wp-includes/ms-load.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludestemplateloaderphp">trunk/wp-includes/template-loader.php</a></li>
<li><a href="#trunkwpincludeswpdbphp">trunk/wp-includes/wp-db.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ms.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ms.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-admin/includes/ms.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">                         $wpdb-&gt;query( &quot;DROP TABLE IF EXISTS &quot;. current( $drop_table ) .&quot;&quot; );
</span><span class="cx">                 }
</span><span class="cx">                 $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;blogs WHERE blog_id = %d&quot;, $blog_id) );
</span><del>-                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', constant( &quot;WP_CONTENT_DIR&quot; ) . &quot;/blogs.dir/{$blog_id}/files/&quot;, $blog_id );
</del><ins>+                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . &quot;/blogs.dir/{$blog_id}/files/&quot;, $blog_id );
</ins><span class="cx">                 $dir = rtrim($dir, DIRECTORY_SEPARATOR);
</span><span class="cx">                 $top_dir = $dir;
</span><span class="cx">                 $stack = array($dir);
</span></span></pre></div>
<a id="trunkwpadminincludesupgradephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/upgrade.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/upgrade.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-admin/includes/upgrade.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -1259,11 +1259,11 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         if ( $setting == 'home' &amp;&amp; defined( 'WP_HOME' ) ) {
</span><del>-                return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
</del><ins>+                return preg_replace( '|/+$|', '', WP_HOME );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( $setting == 'siteurl' &amp;&amp; defined( 'WP_SITEURL' ) ) {
</span><del>-                return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) );
</del><ins>+                return preg_replace( '|/+$|', '', WP_SITEURL );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         $option = $wpdb-&gt;get_var( $wpdb-&gt;prepare(&quot;SELECT option_value FROM $wpdb-&gt;options WHERE option_name = %s&quot;, $setting) );
</span></span></pre></div>
<a id="trunkwpadminrevisionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/revision.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/revision.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-admin/revision.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx">         if ( !$post = get_post( $revision-&gt;post_parent ) )
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><del>-        if ( !constant('WP_POST_REVISIONS') &amp;&amp; !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
</del><ins>+        if ( ! WP_POST_REVISIONS &amp;&amp; !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
</ins><span class="cx">                 break;
</span><span class="cx"> 
</span><span class="cx">         check_admin_referer( &quot;restore-post_$post-&gt;ID|$revision-&gt;ID&quot; );
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">         else
</span><span class="cx">                 break; // Don't diff two unrelated revisions
</span><span class="cx"> 
</span><del>-        if ( !constant('WP_POST_REVISIONS') ) { // Revisions disabled
</del><ins>+        if ( ! WP_POST_REVISIONS ) { // Revisions disabled
</ins><span class="cx">                 if (
</span><span class="cx">                         // we're not looking at an autosave
</span><span class="cx">                         ( !wp_is_post_autosave( $left_revision ) &amp;&amp; !wp_is_post_autosave( $right_revision ) )
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">         if ( !current_user_can( 'read_post', $revision-&gt;ID ) || !current_user_can( 'read_post', $post-&gt;ID ) )
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><del>-        if ( !constant('WP_POST_REVISIONS') &amp;&amp; !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
</del><ins>+        if ( ! WP_POST_REVISIONS &amp;&amp; !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
</ins><span class="cx">                 break;
</span><span class="cx"> 
</span><span class="cx">         $post_type_object = get_post_type_object($post-&gt;post_type);
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> 
</span><span class="cx"> $args = array( 'format' =&gt; 'form-table', 'parent' =&gt; true, 'right' =&gt; $right, 'left' =&gt; $left );
</span><del>-if ( !constant( 'WP_POST_REVISIONS' ) )
</del><ins>+if ( ! WP_POST_REVISIONS )
</ins><span class="cx">         $args['type'] = 'autosave';
</span><span class="cx"> 
</span><span class="cx"> wp_list_post_revisions( $post, $args );
</span></span></pre></div>
<a id="trunkwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-functions.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-functions.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-includes/ms-functions.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -1274,8 +1274,7 @@
</span><span class="cx"> 
</span><span class="cx"> function maybe_redirect_404() {
</span><span class="cx">         global $current_site;
</span><del>-        if ( is_main_site() &amp;&amp; is_404() &amp;&amp; defined( 'NOBLOGREDIRECT' ) &amp;&amp; constant( 'NOBLOGREDIRECT' ) != '' ) {
-                $destination = constant( 'NOBLOGREDIRECT' );
</del><ins>+        if ( is_main_site() &amp;&amp; is_404() &amp;&amp; defined( 'NOBLOGREDIRECT' ) &amp;&amp; ( $destination = NOBLOGREDIRECT ) ) {
</ins><span class="cx">                 if ( $destination == '%siteurl%' )
</span><span class="cx">                         $destination = $current_site-&gt;domain . $current_site-&gt;path;
</span><span class="cx">                 wp_redirect( $destination );
</span></span></pre></div>
<a id="trunkwpincludesmsloadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-load.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-load.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-includes/ms-load.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> function wpmu_current_site() {
</span><span class="cx">         global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
</span><span class="cx">         if ( defined( 'DOMAIN_CURRENT_SITE' ) &amp;&amp; defined( 'PATH_CURRENT_SITE' ) ) {
</span><del>-                $current_site-&gt;id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
</del><ins>+                $current_site-&gt;id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
</ins><span class="cx">                 $current_site-&gt;domain = DOMAIN_CURRENT_SITE;
</span><span class="cx">                 $current_site-&gt;path   = $path = PATH_CURRENT_SITE;
</span><span class="cx">                 if ( defined( 'BLOGID_CURRENT_SITE' ) )
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-includes/post.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -4169,7 +4169,7 @@
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         // WP_POST_REVISIONS = 0, false
</span><del>-        if ( !constant('WP_POST_REVISIONS') )
</del><ins>+        if ( ! WP_POST_REVISIONS )
</ins><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         if ( !$post = get_post( $post_id, ARRAY_A ) )
</span><span class="lines">@@ -4448,7 +4448,7 @@
</span><span class="cx">  * @return array empty if no revisions
</span><span class="cx">  */
</span><span class="cx"> function wp_get_post_revisions( $post_id = 0, $args = null ) {
</span><del>-        if ( !constant('WP_POST_REVISIONS') )
</del><ins>+        if ( ! WP_POST_REVISIONS )
</ins><span class="cx">                 return array();
</span><span class="cx">         if ( ( !$post = get_post( $post_id ) ) || empty( $post-&gt;ID ) )
</span><span class="cx">                 return array();
</span></span></pre></div>
<a id="trunkwpincludestemplateloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/template-loader.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/template-loader.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-includes/template-loader.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx">  * Loads the correct template based on the visitor's url
</span><span class="cx">  * @package WordPress
</span><span class="cx">  */
</span><del>-if ( defined('WP_USE_THEMES') &amp;&amp; constant('WP_USE_THEMES') ) {
</del><ins>+if ( defined('WP_USE_THEMES') &amp;&amp; WP_USE_THEMES ) {
</ins><span class="cx">         do_action('template_redirect');
</span><span class="cx">         if ( is_robots() ) {
</span><span class="cx">                 do_action('do_robots');
</span></span></pre></div>
<a id="trunkwpincludeswpdbphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/wp-db.php (13208 => 13209)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/wp-db.php        2010-02-19 00:28:44 UTC (rev 13208)
+++ trunk/wp-includes/wp-db.php        2010-02-19 01:03:58 UTC (rev 13209)
</span><span class="lines">@@ -345,7 +345,7 @@
</span><span class="cx">          * @param string $dbhost MySQL database host
</span><span class="cx">          */
</span><span class="cx">         function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
</span><del>-                if( defined( &quot;WP_USE_MULTIPLE_DB&quot; ) &amp;&amp; CONSTANT( &quot;WP_USE_MULTIPLE_DB&quot; ) == true )
</del><ins>+                if( defined( 'WP_USE_MULTIPLE_DB' ) &amp;&amp; WP_USE_MULTIPLE_DB )
</ins><span class="cx">                         $this-&gt;db_connect();
</span><span class="cx">                 return $this-&gt;__construct($dbuser, $dbpassword, $dbname, $dbhost);
</span><span class="cx">         }
</span><span class="lines">@@ -367,23 +367,22 @@
</span><span class="cx">         function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
</span><span class="cx">                 register_shutdown_function(array(&amp;$this, &quot;__destruct&quot;));
</span><span class="cx"> 
</span><del>-                if ( defined( 'WP_DEBUG' ) &amp;&amp; WP_DEBUG )
</del><ins>+                if ( WP_DEBUG )
</ins><span class="cx">                         $this-&gt;show_errors();
</span><span class="cx"> 
</span><span class="cx">                 if ( is_multisite() ) {
</span><span class="cx">                         $this-&gt;charset = 'utf8';
</span><del>-                        if ( defined( 'DB_COLLATE' ) &amp;&amp; constant( 'DB_COLLATE' ) != '' )
-                                $this-&gt;collate = constant( 'DB_COLLATE' );
</del><ins>+                        if ( defined( 'DB_COLLATE' ) &amp;&amp; DB_COLLATE )
+                                $this-&gt;collate = DB_COLLATE;
</ins><span class="cx">                         else
</span><span class="cx">                                 $this-&gt;collate = 'utf8_general_ci';
</span><ins>+                } elseif ( defined( 'DB_COLLATE' ) ) {
+                        $this-&gt;collate = DB_COLLATE;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ( defined('DB_CHARSET') )
</span><span class="cx">                         $this-&gt;charset = DB_CHARSET;
</span><span class="cx"> 
</span><del>-                if ( defined('DB_COLLATE') )
-                        $this-&gt;collate = DB_COLLATE;
-
</del><span class="cx">                 $this-&gt;dbuser = $dbuser;
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
</span><span class="lines">@@ -666,7 +665,7 @@
</span><span class="cx">                 if ( is_multisite() ) {
</span><span class="cx">                         $msg = &quot;WordPress database error: [$str]\n{$this-&gt;last_query}\n&quot;;
</span><span class="cx">                         if ( defined( 'ERRORLOGFILE' ) )
</span><del>-                                error_log( $msg, 3, CONSTANT( 'ERRORLOGFILE' ) );
</del><ins>+                                error_log( $msg, 3, ERRORLOGFILE );
</ins><span class="cx">                         if ( defined( 'DIEONDBERROR' ) )
</span><span class="cx">                                 die( $msg );
</span><span class="cx">                 } else {
</span><span class="lines">@@ -807,7 +806,7 @@
</span><span class="cx">                 // use $this-&gt;dbh for read ops, and $this-&gt;dbhwrite for write ops
</span><span class="cx">                 // use $this-&gt;dbhglobal for gloal table ops
</span><span class="cx">                 unset( $dbh );
</span><del>-                if( defined( &quot;WP_USE_MULTIPLE_DB&quot; ) &amp;&amp; CONSTANT( &quot;WP_USE_MULTIPLE_DB&quot; ) == true ) {
</del><ins>+                if( defined( 'WP_USE_MULTIPLE_DB' ) &amp;&amp; WP_USE_MULTIPLE_DB ) {
</ins><span class="cx">                         if( $this-&gt;blogs != '' &amp;&amp; preg_match(&quot;/(&quot; . $this-&gt;blogs . &quot;|&quot; . $this-&gt;users . &quot;|&quot; . $this-&gt;usermeta . &quot;|&quot; . $this-&gt;site . &quot;|&quot; . $this-&gt;sitemeta . &quot;|&quot; . $this-&gt;sitecategories . &quot;)/i&quot;,$query) ) {
</span><span class="cx">                                 if( false == isset( $this-&gt;dbhglobal ) ) {
</span><span class="cx">                                         $this-&gt;db_connect( $query );
</span></span></pre>
</div>
</div>

</body>
</html>