Changeset 13324
- Timestamp:
- 02/23/2010 09:06:50 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/maint/repair.php
r13229 r13324 32 32 $okay = true; 33 33 34 $tables = $wpdb->tables( 'all' , true);34 $tables = $wpdb->tables( 'all' ); 35 35 // Loop over the WP tables, checking and repairing as needed. 36 36 foreach ( $tables as $table ) { -
trunk/wp-includes/wp-db.php
r13314 r13324 96 96 * @var int 97 97 */ 98 var $num_rows = 0; 98 var $num_rows = 0; 99 99 100 100 /** … … 364 364 365 365 /** 366 * List of Multisiteglobal tables366 * List of WordPress global tables 367 367 * 368 368 * @since 3.0.0 … … 371 371 * @var array 372 372 */ 373 var $ms_tables = array( 'blogs', 'signups', 'site', 'sitemeta', 374 'sitecategories', 'registration_log', 'blog_versions' ); 375 376 /** 377 * List of WordPress global tables 373 var $global_tables = array( 'users', 'usermeta' ); 374 375 /** 376 * List of Multisite global tables 378 377 * 379 378 * @since 3.0.0 … … 382 381 * @var array 383 382 */ 384 var $global_tables = array( 'users', 'usermeta' ); 383 var $ms_global_tables = array( 'blogs', 'signups', 'site', 'sitemeta', 384 'sitecategories', 'registration_log', 'blog_versions' ); 385 385 386 386 /** 387 387 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized during WP load. 388 * 388 * 389 389 * Keys are column names, values are format types: 'ID' => '%d' 390 390 * … … 534 534 * Sets the table prefix for the WordPress tables. 535 535 * 536 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to537 * override the WordPress users and usersmeta tables that would otherwise be determined by the $prefix.538 *539 536 * @since 2.5.0 540 537 * … … 552 549 $old_prefix = $this->base_prefix; 553 550 $this->base_prefix = $prefix; 554 foreach ( $this->tables( 'global' ) as $table )555 $this->$table = $prefix . $table;551 foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) 552 $this->$table = $prefixed_table; 556 553 557 554 if ( defined( 'VHOST' ) && empty( $this->blogid ) ) … … 560 557 $this->prefix = $this->get_blog_prefix( $this->blogid ); 561 558 562 foreach ( (array) $this->tables( 'blog' ) as $table ) 563 $this->$table = $this->prefix . $table; 564 565 foreach ( (array) $this->tables( 'old' ) as $table ) 566 $this->$table = $this->prefix . $table; 567 568 if ( defined( 'CUSTOM_USER_TABLE' ) ) 569 $this->users = CUSTOM_USER_TABLE; 570 571 if ( defined( 'CUSTOM_USER_META_TABLE' ) ) 572 $this->usermeta = CUSTOM_USER_META_TABLE; 559 foreach ( (array) $this->tables( 'blog' ) as $table => $prefixed_table ) 560 $this->$table = $prefixed_table; 561 562 foreach ( (array) $this->tables( 'old' ) as $table => $prefixed_table ) 563 $this->$table = $prefixed_table; 573 564 574 565 return $old_prefix; … … 583 574 * @param string $site_id. Optional. 584 575 * @return string previous blog id 585 */ 576 */ 586 577 function set_blog_id( $blog_id, $site_id = '' ) { 587 578 if ( ! empty( $site_id ) ) … … 593 584 $this->prefix = $this->get_blog_prefix( $this->blogid ); 594 585 595 foreach ( $this->tables( 'blog' ) as $table )596 $this->$table = $ this->prefix . $table;597 598 foreach ( $this->tables( 'old' ) as $table )599 $this->$table = $ this->prefix . $table;586 foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) 587 $this->$table = $prefixed_table; 588 589 foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) 590 $this->$table = $prefixed_table; 600 591 601 592 return $old_blog_id; … … 624 615 * Returns an array of WordPress tables. 625 616 * 617 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to 618 * override the WordPress users and usersmeta tables that would otherwise 619 * be determined by the prefix. 620 * 626 621 * @since 3.0.0 627 622 * @uses wpdb::tables 628 623 * @uses wpdb::old_tables 629 624 * @uses wpdb::global_tables 625 * @uses wpdb::ms_global_tables 630 626 * @uses is_multisite() 631 627 * 632 628 * @param string $scope Can be all, global, blog, or old tables. Default all. 633 * All returns all global tables and the blog tables for the queried blog. 634 * @param bool $prefix Whether to include the blog prefix. Default false. 635 * @param int $blog_id The blog_id to prefix. Defaults to main blog. 636 * @return array Table names. 637 */ 638 function tables( $scope = 'all', $prefix = false, $blog_id = 0 ) { 629 * All returns the blog tables for the queried blog and all global tables. 630 * @param bool $prefix Whether to include table prefixes. Default false. If blog 631 * prefix is requested, then the custom users and usermeta tables will be mapped. 632 * @param int $blog_id The blog_id to prefix. Defaults to main blog. Used only when prefix is requested. 633 * @return array Table names. When a prefix is requested, the key is the 634 * unprefixed table name. 635 */ 636 function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) { 639 637 switch ( $scope ) { 640 638 case 'old' : … … 645 643 break; 646 644 case 'global' : 647 $tables = array_merge( $this->global_tables, $this->ms_tables ); 645 $tables = $this->global_tables; 646 if ( is_multisite() ) 647 $tables = array_merge( $tables, $this->ms_global_tables ); 648 648 break; 649 649 case 'all' : 650 650 $tables = array_merge( $this->global_tables, $this->tables ); 651 651 if ( is_multisite() ) 652 $tables = array_merge( $tables, $this->ms_ tables );652 $tables = array_merge( $tables, $this->ms_global_tables ); 653 653 break; 654 654 } … … 656 656 if ( $prefix ) { 657 657 $prefix = $this->get_blog_prefix( $blog_id ); 658 $base_prefix = $this->base_prefix; 659 $global_tables = array_merge( $this->global_tables, $this->ms_global_tables ); 658 660 foreach ( $tables as $k => $table ) { 659 $tables[$k] = $prefix . $table; 661 if ( in_array( $table, $global_tables ) ) 662 $tables[ $table ] = $base_prefix . $table; 663 else 664 $tables[ $table ] = $prefix . $table; 665 unset( $tables[ $k ] ); 660 666 } 667 668 if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) ) 669 $tables['users'] = CUSTOM_USER_TABLE; 670 671 if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) ) 672 $tables['usermeta'] = CUSTOM_USER_META_TABLE; 661 673 } 662 674 … … 786 798 * Prepares a SQL query for safe execution. Uses sprintf()-like syntax. 787 799 * 788 * The following directives can be used in the query format string: 789 * %d (decimal number) 800 * The following directives can be used in the query format string: 801 * %d (decimal number) 790 802 * %s (string) 791 * %% (literal percentage sign - no argument needed) 792 * 793 * Both %d and %s are to be left unquoted in the query string and 803 * %% (literal percentage sign - no argument needed) 804 * 805 * Both %d and %s are to be left unquoted in the query string and 794 806 * they need an argument passed for them. Literals (%) as parts of 795 807 * the query must be properly written as %%.
Note: See TracChangeset
for help on using the changeset viewer.