Changeset 13229
- Timestamp:
- 02/19/2010 07:57:03 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/maint/repair.php
r13224 r13229 32 32 $okay = true; 33 33 34 $tables = array_merge( $wpdb->tables, is_multisite() ? $wpdb->global_tables : array( 'users', 'usermeta' ) ); 35 $prefix = $wpdb->prefix; 36 if ( is_multisite() && ! defined('MULTISITE') ) // _1 to get MU-era main blog 37 $prefix .= '_1'; 38 34 $tables = $wpdb->tables( 'all', true ); 39 35 // Loop over the WP tables, checking and repairing as needed. 40 36 foreach ( $tables as $table ) { 41 if ( in_array( $table, $wpdb->old_tables ) ) 42 continue; 43 44 $check = $wpdb->get_row("CHECK TABLE {$prefix}$table"); 37 $check = $wpdb->get_row("CHECK TABLE $table"); 45 38 if ( 'OK' == $check->Msg_text ) { 46 echo "<p>The {$prefix}$table table is okay.";39 echo "<p>The $table table is okay."; 47 40 } else { 48 echo "<p>The {$prefix}$table table is not okay. It is reporting the following error: <code>$check->Msg_text</code>. WordPress will attempt to repair this table…";49 $repair = $wpdb->get_row("REPAIR TABLE {$prefix}$table");41 echo "<p>The $table table is not okay. It is reporting the following error: <code>$check->Msg_text</code>. WordPress will attempt to repair this table…"; 42 $repair = $wpdb->get_row("REPAIR TABLE $table"); 50 43 if ( 'OK' == $check->Msg_text ) { 51 echo "<br /> Successfully repaired the {$prefix}$table table.";44 echo "<br /> Successfully repaired the $table table."; 52 45 } else { 53 echo "<br /> Failed to repair the {prefix}$table table. Error: $check->Msg_text<br />";54 $problems[" {$prefix}$table"] = $check->Msg_text;46 echo "<br /> Failed to repair the $table table. Error: $check->Msg_text<br />"; 47 $problems["$table"] = $check->Msg_text; 55 48 $okay = false; 56 49 } 57 50 } 58 51 if ( $okay && $optimize ) { 59 $check = $wpdb->get_row("ANALYZE TABLE {$prefix}$table");52 $check = $wpdb->get_row("ANALYZE TABLE $table"); 60 53 if ( 'Table is already up to date' == $check->Msg_text ) { 61 echo "<br /> The {$prefix}$table table is already optimized.";54 echo "<br /> The $table table is already optimized."; 62 55 } else { 63 $check = $wpdb->get_row("OPTIMIZE TABLE {$prefix}$table");56 $check = $wpdb->get_row("OPTIMIZE TABLE $table"); 64 57 if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) 65 echo "<br /> Successfully optimized the {$prefix}$table table.";58 echo "<br /> Successfully optimized the $table table."; 66 59 else 67 echo "<br /> Failed to optimize the {$prefix}$table table. Error: $check->Msg_text";60 echo "<br /> Failed to optimize the $table table. Error: $check->Msg_text"; 68 61 } 69 62 } -
trunk/wp-includes/deprecated.php
r13098 r13229 2 2 /** 3 3 * Deprecated functions from past WordPress versions. You shouldn't use these 4 * globals and functions and look for the alternatives instead. The functions5 * and globals will beremoved in a later version.4 * functions and look for the alternatives instead. The functions will be 5 * removed in a later version. 6 6 * 7 7 * @package WordPress 8 8 * @subpackage Deprecated 9 9 */ 10 11 /*12 * Deprecated global variables.13 */14 15 /**16 * The name of the Posts table17 * @global string $tableposts18 * @deprecated Use $wpdb->posts19 */20 $tableposts = $wpdb->posts;21 22 /**23 * The name of the Users table24 * @global string $tableusers25 * @deprecated Use $wpdb->users26 */27 $tableusers = $wpdb->users;28 29 /**30 * The name of the Categories table31 * @global string $tablecategories32 * @deprecated Use $wpdb->categories33 */34 $tablecategories = $wpdb->categories;35 36 /**37 * The name of the post to category table38 * @global string $tablepost2cat39 * @deprecated Use $wpdb->post2cat;40 */41 $tablepost2cat = $wpdb->post2cat;42 43 /**44 * The name of the comments table45 * @global string $tablecomments46 * @deprecated Use $wpdb->comments;47 */48 $tablecomments = $wpdb->comments;49 50 /**51 * The name of the links table52 * @global string $tablelinks53 * @deprecated Use $wpdb->links;54 */55 $tablelinks = $wpdb->links;56 57 /**58 * @global string $tablelinkcategories59 * @deprecated Not used anymore;60 */61 $tablelinkcategories = 'linkcategories_is_gone';62 63 /**64 * The name of the options table65 * @global string $tableoptions66 * @deprecated Use $wpdb->options;67 */68 $tableoptions = $wpdb->options;69 70 /**71 * The name of the postmeta table72 * @global string $tablepostmeta73 * @deprecated Use $wpdb->postmeta;74 */75 $tablepostmeta = $wpdb->postmeta;76 10 77 11 /* -
trunk/wp-includes/functions.php
r13210 r13229 1828 1828 $wpdb->suppress_errors( $suppress ); 1829 1829 1830 $wp_tables = $wpdb->tables( 'all', true ); 1830 1831 // Loop over the WP tables. If none exist, then scratch install is allowed. 1831 1832 // If one or more exist, suggest table repair since we got here because the options 1832 1833 // table could not be accessed. 1833 foreach ( $wpdb->tables as $table) {1834 foreach ( $wp_tables as $table ) { 1834 1835 // If one of the WP tables exist, then we are in an insane state. 1835 if ( in_array( $wpdb->prefix . $table, $tables) ) {1836 if ( in_array( $table, $tables ) ) { 1836 1837 // If visiting repair.php, return true and let it take over. 1837 1838 if ( defined('WP_REPAIRING') ) -
trunk/wp-includes/wp-db.php
r13209 r13229 138 138 var $blogid = 0; 139 139 var $siteid = 0; 140 var $blogs;141 var $signups;142 var $site;143 var $sitemeta;144 var $sitecategories;145 var $global_tables = array('blogs', 'signups', 'site', 'sitemeta', 'users', 'usermeta', 'sitecategories', 'registration_log', 'blog_versions');146 140 147 141 /** … … 164 158 165 159 /** 166 * WordPress C ategories table160 * WordPress Comments table 167 161 * 168 162 * @since 1.5.0 … … 170 164 * @var string 171 165 */ 172 var $c ategories;173 174 /** 175 * WordPress Post to Categorytable166 var $comments; 167 168 /** 169 * WordPress Links table 176 170 * 177 171 * @since 1.5.0 … … 179 173 * @var string 180 174 */ 181 var $ post2cat;182 183 /** 184 * WordPress Comments table175 var $links; 176 177 /** 178 * WordPress Options table 185 179 * 186 180 * @since 1.5.0 … … 188 182 * @var string 189 183 */ 190 var $comments;191 192 /**193 * WordPress Links table194 *195 * @since 1.5.0196 * @access public197 * @var string198 */199 var $links;200 201 /**202 * WordPress Options table203 *204 * @since 1.5.0205 * @access public206 * @var string207 */208 184 var $options; 209 185 … … 263 239 264 240 /** 265 * List of WordPress tables241 * List of WordPress per-blog tables 266 242 * 267 243 * @since {@internal Version Unknown}} 268 244 * @access private 245 * @see wpdb::tables() 269 246 * @var array 270 247 */ 271 var $tables = array( 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',272 'postmeta', 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta');248 var $tables = array( 'posts', 'comments', 'links', 'options', 'postmeta', 249 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta' ); 273 250 274 251 /** … … 277 254 * @since 2.9.0 278 255 * @access private 256 * @see wpdb::tables() 279 257 * @var array 280 258 */ 281 var $old_tables = array('categories', 'post2cat', 'link2cat'); 282 283 284 /** 285 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php. 259 var $old_tables = array( 'categories', 'post2cat', 'link2cat' ); 260 261 /** 262 * Multisite Blogs table 263 * 264 * @since 3.0.0 265 * @access public 266 * @var string 267 */ 268 var $blogs; 269 270 /** 271 * Multisite Signups table 272 * 273 * @since 3.0.0 274 * @access public 275 * @var string 276 */ 277 var $signups; 278 279 /** 280 * Multisite Sites table 281 * 282 * @since 3.0.0 283 * @access public 284 * @var string 285 */ 286 var $site; 287 288 /** 289 * Multisite Site Metadata table 290 * 291 * @since 3.0.0 292 * @access public 293 * @var string 294 */ 295 var $sitemeta; 296 297 /** 298 * Multisite Sitewide Terms table 299 * 300 * @since 3.0.0 301 * @access public 302 * @var string 303 */ 304 var $sitecategories; 305 306 /** 307 * Multisite Registration Log table 308 * 309 * @since 3.0.0 310 * @access public 311 * @var string 312 */ 313 var $registration_log; 314 315 /** 316 * Multisite Blog Versions table 317 * 318 * @since 3.0.0 319 * @access public 320 * @var string 321 */ 322 var $blog_versions; 323 324 /** 325 * List of Multisite global tables 326 * 327 * @since 3.0.0 328 * @access private 329 * @see wpdb::tables() 330 * @var array 331 */ 332 var $ms_tables = array( 'blogs', 'signups', 'site', 'sitemeta', 333 'sitecategories', 'registration_log', 'blog_versions' ); 334 335 /** 336 * List of WordPress global tables 337 * 338 * @since 3.0.0 339 * @access private 340 * @see wpdb::tables() 341 * @var array 342 */ 343 var $global_tables = array( 'users', 'usermeta' ); 344 345 /** 346 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized in wp-settings.php. 286 347 * 287 348 * Keys are colmn names, values are format types: 'ID' => '%d' … … 291 352 * @see wpdb:insert() 292 353 * @see wpdb:update() 354 * @see wp_set_wpdb_vars() 293 355 * @access public 294 356 * @var array … … 440 502 * @return string|WP_Error Old prefix or WP_Error on error 441 503 */ 442 function set_prefix( $prefix) {504 function set_prefix( $prefix ) { 443 505 444 506 if ( preg_match('|[^a-z0-9_]|i', $prefix) ) … … 453 515 $old_prefix = $this->base_prefix; 454 516 $this->base_prefix = $prefix; 455 foreach ( $this-> global_tablesas $table )517 foreach ( $this->tables( 'global' ) as $table ) 456 518 $this->$table = $prefix . $table; 457 519 458 if ( defined('VHOST') && empty( $this->blogid) )520 if ( defined('VHOST') && empty( $this->blogid ) ) 459 521 return $old_prefix; 460 522 461 523 $this->prefix = $this->get_blog_prefix( $this->blogid ); 462 524 463 foreach ( (array) $this->tables as $table ) 525 foreach ( (array) $this->tables( 'blog' ) as $table ) 526 $this->$table = $this->prefix . $table; 527 528 foreach ( (array) $this->tables( 'old' ) as $table ) 464 529 $this->$table = $this->prefix . $table; 465 530 … … 482 547 $this->prefix = $this->get_blog_prefix( $this->blogid ); 483 548 484 foreach ( $this->tables as $table ) 549 foreach ( $this->tables( 'blog' ) as $table ) 550 $this->$table = $this->prefix . $table; 551 552 foreach ( $this->tables( 'old' ) as $table ) 485 553 $this->$table = $this->prefix . $table; 486 554 … … 497 565 return $this->base_prefix; 498 566 } 567 } 568 569 /** 570 * Returns an array of WordPress tables. 571 * 572 * @since 3.0.0 573 * @uses wpdb::tables 574 * @uses wpdb::old_tables 575 * @uses wpdb::global_tables 576 * @uses is_multisite() 577 * 578 * @param string $scope Can be all, global, blog, or old tables. Default all. 579 * All returns all global tables and the blog tables for the queried blog. 580 * @param bool $prefix Whether to include the blog prefix. Default false. 581 * @param int $blog_id The blog_id to prefix. Defaults to main blog. 582 * @return array Table names. 583 */ 584 function tables( $scope = 'all', $prefix = false, $blog_id = 0 ) { 585 switch ( $scope ) { 586 case 'old' : 587 $tables = $this->old_tables; 588 break; 589 case 'blog' : 590 $tables = $this->tables; 591 break; 592 case 'global' : 593 $tables = array_merge( $this->global_tables, $this->ms_tables ); 594 break; 595 case 'all' : 596 $tables = array_merge( $this->global_tables, $this->tables ); 597 if ( is_multisite() ) 598 $tables = array_merge( $tables, $this->ms_tables ); 599 break; 600 } 601 602 if ( $prefix ) { 603 $prefix = $this->get_blog_prefix( $blog_id ); 604 foreach ( $tables as &$table ) { 605 $table = $prefix . $table; 606 } 607 } 608 609 return $tables; 499 610 } 500 611
Note: See TracChangeset
for help on using the changeset viewer.