Ticket #12362: 12362_4th-iteration.patch
File 12362_4th-iteration.patch, 6.0 KB (added by , 15 years ago) |
---|
-
wp-db.php
20 20 define( 'OBJECT', 'OBJECT', true ); 21 21 22 22 /** 23 * @since {@internal Version Unknown}}23 * @since 2.5.0 24 24 */ 25 25 define( 'OBJECT_K', 'OBJECT_K', false ); 26 26 … … 119 119 /** 120 120 * Results of the last query made 121 121 * 122 * @since {@internal Version Unknown}}122 * @since 1.0.0 123 123 * @access private 124 124 * @var array|null 125 125 */ … … 186 186 /** 187 187 * List of WordPress per-blog tables 188 188 * 189 * @since {@internal Version Unknown}}189 * @since 2.5.0 190 190 * @access private 191 191 * @see wpdb::tables() 192 192 * @var array … … 266 266 /** 267 267 * WordPress Post Metadata table 268 268 * 269 * @since {@internal Version Unknown}}269 * @since 1.5.0 270 270 * @access public 271 271 * @var string 272 272 */ … … 470 470 * the actual setting up of the class properties and connection 471 471 * to the database. 472 472 * 473 * #3354: register_shutdown_function prevents this object from 474 * unloading to prevent fatal errors. 475 * 473 476 * @since 2.0.8 474 477 * 475 478 * @param string $dbuser MySQL database user … … 533 536 /** 534 537 * PHP5 style destructor and will run when database object is destroyed. 535 538 * 539 * @see wpdb::__construct() 536 540 * @since 2.0.8 537 541 * @return bool true 538 542 */ … … 614 618 */ 615 619 function get_blog_prefix( $blog_id = 0 ) { 616 620 if ( is_multisite() && $blog_id ) { 617 if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ))621 if ( defined( 'MULTISITE' ) && 1 == $blog_id ) 618 622 return $this->base_prefix; 619 623 else 620 624 return $this->base_prefix . $blog_id . '_'; … … 633 637 * The scope argument can take one of the following: 634 638 * 635 639 * 'all' - returns 'all' and 'global' tables. No old tables are returned. 640 * 'blog' - returns the blog-level tables for the queried blog. 636 641 * 'global' - returns the global tables for the installation, returning multisite tables only if running multisite. 637 642 * 'ms_global' - returns the multisite global tables, regardless if current installation is multisite. 638 * 'blog' - returns the blog-level tables for the queried blog.639 643 * 'old' - returns tables which are deprecated. 640 644 * 641 645 * @since 3.0.0 … … 648 652 * @param string $scope Optional. Can be all, global, ms_global, blog, or old tables. Defaults to all. 649 653 * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog 650 654 * prefix is requested, then the custom users and usermeta tables will be mapped. 651 * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb:: blogid. Used only when prefix is requested.655 * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb::$blogid. Used only when prefix is requested. 652 656 * @return array Table names. When a prefix is requested, the key is the unprefixed table name. 653 657 */ 654 658 function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) { … … 658 662 if ( is_multisite() ) 659 663 $tables = array_merge( $tables, $this->ms_global_tables ); 660 664 break; 665 case 'blog' : 666 $tables = $this->tables; 667 break; 661 668 case 'global' : 662 669 $tables = $this->global_tables; 663 670 if ( is_multisite() ) … … 666 673 case 'ms_global' : 667 674 $tables = $this->ms_global_tables; 668 675 break; 669 case 'blog' :670 $tables = $this->tables;671 break;672 676 case 'old' : 673 677 $tables = $this->old_tables; 674 678 break; 675 679 default : 676 680 return array(); 677 break;678 681 } 679 682 680 683 if ( $prefix ) { … … 685 688 $global_tables = array_merge( $this->global_tables, $this->ms_global_tables ); 686 689 foreach ( $tables as $k => $table ) { 687 690 if ( in_array( $table, $global_tables ) ) 688 $tables[ $table] = $base_prefix . $table;691 $tables[$table] = $base_prefix . $table; 689 692 else 690 $tables[ $table] = $blog_prefix . $table;691 unset( $tables[ $k] );693 $tables[$table] = $blog_prefix . $table; 694 unset( $tables[$k] ); 692 695 } 693 696 694 697 if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) ) … … 732 735 * Weak escape, using addslashes() 733 736 * 734 737 * @see addslashes() 735 * @since {@internal Version Unknown}}738 * @since 2.8.0 736 739 * @access private 737 740 * 738 * @param 741 * @param string $string 739 742 * @return string 740 743 */ 741 744 function _weak_escape( $string ) { … … 870 873 $args = $args[0]; 871 874 $query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it 872 875 $query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting 873 $query = preg_replace( '|(?<!%)%s|', "'%s'", $query); // quote the strings, avoiding escaped strings like %%s876 $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s 874 877 array_walk( $args, array( &$this, 'escape_by_ref' ) ); 875 878 return @vsprintf( $query, $args ); 876 879 } … … 895 898 return false; 896 899 897 900 if ( $caller = $this->get_caller() ) 898 $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller);901 $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller ); 899 902 else 900 $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query);903 $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query ); 901 904 902 if ( function_exists('error_log') && $log_file = @ini_get('error_log') && ( 'syslog' == $log_file || is_writable( $log_file ) ) ) 903 @error_log( $error_str, 0 ); 905 if ( function_exists( 'error_log' ) 906 && $log_file = @ini_get( 'error_log' ) 907 && ( 'syslog' == $log_file || @is_writable( $log_file ) ) ) 908 @error_log( $error_str ); 904 909 905 // Is error output turned on or not..910 // Show Errors ? 906 911 if ( ! $this->show_errors ) 907 912 return false; 908 913