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 #12041, see #11644

git-svn-id: http://svn.automattic.com/wordpress/trunk@13209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-02-19 01:03:58 +00:00
parent aba18243f0
commit 84da5911aa
8 changed files with 20 additions and 22 deletions

View File

@ -75,7 +75,7 @@ function wpmu_delete_blog($blog_id, $drop = false) {
$wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" );
}
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id) );
$dir = apply_filters( 'wpmu_delete_blog_upload_dir', constant( "WP_CONTENT_DIR" ) . "/blogs.dir/{$blog_id}/files/", $blog_id );
$dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$top_dir = $dir;
$stack = array($dir);

View File

@ -1259,11 +1259,11 @@ function __get_option($setting) {
global $wpdb;
if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
return preg_replace( '|/+$|', '', WP_HOME );
}
if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) );
return preg_replace( '|/+$|', '', WP_SITEURL );
}
$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting) );

View File

@ -29,7 +29,7 @@ case 'restore' :
if ( !$post = get_post( $revision->post_parent ) )
break;
if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
if ( ! WP_POST_REVISIONS && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
break;
check_admin_referer( "restore-post_$post->ID|$revision->ID" );
@ -68,7 +68,7 @@ case 'diff' :
else
break; // Don't diff two unrelated revisions
if ( !constant('WP_POST_REVISIONS') ) { // Revisions disabled
if ( ! WP_POST_REVISIONS ) { // Revisions disabled
if (
// we're not looking at an autosave
( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )
@ -106,7 +106,7 @@ default :
if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
break;
if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
if ( ! WP_POST_REVISIONS && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
break;
$post_type_object = get_post_type_object($post->post_type);
@ -207,7 +207,7 @@ endif;
<?php
$args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
if ( !constant( 'WP_POST_REVISIONS' ) )
if ( ! WP_POST_REVISIONS )
$args['type'] = 'autosave';
wp_list_post_revisions( $post, $args );

View File

@ -1274,8 +1274,7 @@ function signup_nonce_check( $result ) {
function maybe_redirect_404() {
global $current_site;
if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) {
$destination = constant( 'NOBLOGREDIRECT' );
if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = NOBLOGREDIRECT ) ) {
if ( $destination == '%siteurl%' )
$destination = $current_site->domain . $current_site->path;
wp_redirect( $destination );

View File

@ -98,7 +98,7 @@ function get_current_site_name( $current_site ) {
function wpmu_current_site() {
global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
$current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
$current_site->domain = DOMAIN_CURRENT_SITE;
$current_site->path = $path = PATH_CURRENT_SITE;
if ( defined( 'BLOGID_CURRENT_SITE' ) )

View File

@ -4169,7 +4169,7 @@ function wp_save_post_revision( $post_id ) {
return;
// WP_POST_REVISIONS = 0, false
if ( !constant('WP_POST_REVISIONS') )
if ( ! WP_POST_REVISIONS )
return;
if ( !$post = get_post( $post_id, ARRAY_A ) )
@ -4448,7 +4448,7 @@ function wp_delete_post_revision( $revision_id ) {
* @return array empty if no revisions
*/
function wp_get_post_revisions( $post_id = 0, $args = null ) {
if ( !constant('WP_POST_REVISIONS') )
if ( ! WP_POST_REVISIONS )
return array();
if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) )
return array();

View File

@ -3,7 +3,7 @@
* Loads the correct template based on the visitor's url
* @package WordPress
*/
if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) {
do_action('template_redirect');
if ( is_robots() ) {
do_action('do_robots');

View File

@ -345,7 +345,7 @@ class wpdb {
* @param string $dbhost MySQL database host
*/
function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
if( defined( "WP_USE_MULTIPLE_DB" ) && CONSTANT( "WP_USE_MULTIPLE_DB" ) == true )
if( defined( 'WP_USE_MULTIPLE_DB' ) && WP_USE_MULTIPLE_DB )
$this->db_connect();
return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost);
}
@ -367,23 +367,22 @@ class wpdb {
function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
register_shutdown_function(array(&$this, "__destruct"));
if ( defined( 'WP_DEBUG' ) && WP_DEBUG )
if ( WP_DEBUG )
$this->show_errors();
if ( is_multisite() ) {
$this->charset = 'utf8';
if ( defined( 'DB_COLLATE' ) && constant( 'DB_COLLATE' ) != '' )
$this->collate = constant( 'DB_COLLATE' );
if ( defined( 'DB_COLLATE' ) && DB_COLLATE )
$this->collate = DB_COLLATE;
else
$this->collate = 'utf8_general_ci';
} elseif ( defined( 'DB_COLLATE' ) ) {
$this->collate = DB_COLLATE;
}
if ( defined('DB_CHARSET') )
$this->charset = DB_CHARSET;
if ( defined('DB_COLLATE') )
$this->collate = DB_COLLATE;
$this->dbuser = $dbuser;
$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
@ -666,7 +665,7 @@ class wpdb {
if ( is_multisite() ) {
$msg = "WordPress database error: [$str]\n{$this->last_query}\n";
if ( defined( 'ERRORLOGFILE' ) )
error_log( $msg, 3, CONSTANT( 'ERRORLOGFILE' ) );
error_log( $msg, 3, ERRORLOGFILE );
if ( defined( 'DIEONDBERROR' ) )
die( $msg );
} else {
@ -807,7 +806,7 @@ class wpdb {
// use $this->dbh for read ops, and $this->dbhwrite for write ops
// use $this->dbhglobal for gloal table ops
unset( $dbh );
if( defined( "WP_USE_MULTIPLE_DB" ) && CONSTANT( "WP_USE_MULTIPLE_DB" ) == true ) {
if( defined( 'WP_USE_MULTIPLE_DB' ) && WP_USE_MULTIPLE_DB ) {
if( $this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i",$query) ) {
if( false == isset( $this->dbhglobal ) ) {
$this->db_connect( $query );