Make WordPress Core

Ticket #12362: 12362_4th-iteration.patch

File 12362_4th-iteration.patch, 6.0 KB (added by hakre, 15 years ago)

Patch updated because of missing whitespace fixes.

  • wp-db.php

     
    2020define( 'OBJECT', 'OBJECT', true );
    2121
    2222/**
    23  * @since {@internal Version Unknown}}
     23 * @since 2.5.0
    2424 */
    2525define( 'OBJECT_K', 'OBJECT_K', false );
    2626
     
    119119        /**
    120120         * Results of the last query made
    121121         *
    122          * @since {@internal Version Unknown}}
     122         * @since 1.0.0
    123123         * @access private
    124124         * @var array|null
    125125         */
     
    186186        /**
    187187         * List of WordPress per-blog tables
    188188         *
    189          * @since {@internal Version Unknown}}
     189         * @since 2.5.0
    190190         * @access private
    191191         * @see wpdb::tables()
    192192         * @var array
     
    266266        /**
    267267         * WordPress Post Metadata table
    268268         *
    269          * @since {@internal Version Unknown}}
     269         * @since 1.5.0
    270270         * @access public
    271271         * @var string
    272272         */
     
    470470         * the actual setting up of the class properties and connection
    471471         * to the database.
    472472         *
     473     * #3354: register_shutdown_function prevents this object from
     474         * unloading to prevent fatal errors.
     475     *
    473476         * @since 2.0.8
    474477         *
    475478         * @param string $dbuser MySQL database user
     
    533536        /**
    534537         * PHP5 style destructor and will run when database object is destroyed.
    535538         *
     539         * @see wpdb::__construct()
    536540         * @since 2.0.8
    537541         * @return bool true
    538542         */
     
    614618         */
    615619        function get_blog_prefix( $blog_id = 0 ) {
    616620                if ( is_multisite() && $blog_id ) {
    617                         if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
     621                        if ( defined( 'MULTISITE' ) && 1 == $blog_id )
    618622                                return $this->base_prefix;
    619623                        else
    620624                                return $this->base_prefix . $blog_id . '_';
     
    633637         * The scope argument can take one of the following:
    634638         *
    635639         * 'all' - returns 'all' and 'global' tables. No old tables are returned.
     640         * 'blog' - returns the blog-level tables for the queried blog.
    636641         * 'global' - returns the global tables for the installation, returning multisite tables only if running multisite.
    637642         * 'ms_global' - returns the multisite global tables, regardless if current installation is multisite.
    638          * 'blog' - returns the blog-level tables for the queried blog.
    639643         * 'old' - returns tables which are deprecated.
    640644         *
    641645         * @since 3.0.0
     
    648652         * @param string $scope Optional. Can be all, global, ms_global, blog, or old tables. Defaults to all.
    649653         * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog
    650654         *      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.
    652656         * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
    653657         */
    654658        function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
     
    658662                                if ( is_multisite() )
    659663                                        $tables = array_merge( $tables, $this->ms_global_tables );
    660664                                break;
     665                        case 'blog' :
     666                                $tables = $this->tables;
     667                                break;
    661668                        case 'global' :
    662669                                $tables = $this->global_tables;
    663670                                if ( is_multisite() )
     
    666673                        case 'ms_global' :
    667674                                $tables = $this->ms_global_tables;
    668675                                break;
    669                         case 'blog' :
    670                                 $tables = $this->tables;
    671                                 break;
    672676                        case 'old' :
    673677                                $tables = $this->old_tables;
    674678                                break;
    675679                        default :
    676680                                return array();
    677                                 break;
    678681                }
    679682
    680683                if ( $prefix ) {
     
    685688                        $global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
    686689                        foreach ( $tables as $k => $table ) {
    687690                                if ( in_array( $table, $global_tables ) )
    688                                         $tables[ $table ] = $base_prefix . $table;
     691                                        $tables[$table] = $base_prefix . $table;
    689692                                else
    690                                         $tables[ $table ] = $blog_prefix . $table;
    691                                 unset( $tables[ $k ] );
     693                                        $tables[$table] = $blog_prefix . $table;
     694                                unset( $tables[$k] );
    692695                        }
    693696
    694697                        if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) )
     
    732735         * Weak escape, using addslashes()
    733736         *
    734737         * @see addslashes()
    735          * @since {@internal Version Unknown}}
     738         * @since 2.8.0
    736739         * @access private
    737740         *
    738          * @param  string $string
     741         * @param string $string
    739742         * @return string
    740743         */
    741744        function _weak_escape( $string ) {
     
    870873                        $args = $args[0];
    871874                $query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
    872875                $query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
    873                 $query = preg_replace('|(?<!%)%s|', "'%s'", $query); // quote the strings, avoiding escaped strings like %%s
     876                $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s
    874877                array_walk( $args, array( &$this, 'escape_by_ref' ) );
    875878                return @vsprintf( $query, $args );
    876879        }
     
    895898                        return false;
    896899
    897900                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 );
    899902                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 );
    901904
    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 );
    904909
    905                 // Is error output turned on or not..
     910                // Show Errors ?
    906911                if ( ! $this->show_errors )
    907912                        return false;
    908913