Make WordPress Core

Changeset 28526


Ignore:
Timestamp:
05/19/2014 03:35:29 PM (12 years ago)
Author:
wonderboymusic
Message:

In wpdb, make some things explicitly public. Do not set anything to private. This would instantly blow up hyperdb in the wild.

See #27881, #22234.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r28339 r28526  
    7979         * @var string
    8080         */
    81         var $last_error = '';
     81        public $last_error = '';
    8282
    8383        /**
    … …  
    210210         * @var int
    211211         */
    212         var $blogid = 0;
     212        public $blogid = 0;
    213213
    214214        /**
    … …  
    219219         * @var int
    220220         */
    221         var $siteid = 0;
     221        public $siteid = 0;
    222222
    223223        /**
    … …  
    272272         * @var string
    273273         */
    274         var $comments;
     274        public $comments;
    275275
    276276        /**
    … …  
    281281         * @var string
    282282         */
    283         var $commentmeta;
     283        public $commentmeta;
    284284
    285285        /**
    … …  
    290290         * @var string
    291291         */
    292         var $links;
     292        public $links;
    293293
    294294        /**
    … …  
    299299         * @var string
    300300         */
    301         var $options;
     301        public $options;
    302302
    303303        /**
    … …  
    308308         * @var string
    309309         */
    310         var $postmeta;
     310        public $postmeta;
    311311
    312312        /**
    … …  
    317317         * @var string
    318318         */
    319         var $posts;
     319        public $posts;
    320320
    321321        /**
    … …  
    326326         * @var string
    327327         */
    328         var $terms;
     328        public $terms;
    329329
    330330        /**
    … …  
    335335         * @var string
    336336         */
    337         var $term_relationships;
     337        public $term_relationships;
    338338
    339339        /**
    … …  
    344344         * @var string
    345345         */
    346         var $term_taxonomy;
     346        public $term_taxonomy;
    347347
    348348        /*
    … …  
    357357         * @var string
    358358         */
    359         var $usermeta;
     359        public $usermeta;
    360360
    361361        /**
    … …  
    366366         * @var string
    367367         */
    368         var $users;
     368        public $users;
    369369
    370370        /**
    … …  
    375375         * @var string
    376376         */
    377         var $blogs;
     377        public $blogs;
    378378
    379379        /**
    … …  
    384384         * @var string
    385385         */
    386         var $blog_versions;
     386        public $blog_versions;
    387387
    388388        /**
    … …  
    393393         * @var string
    394394         */
    395         var $registration_log;
     395        public $registration_log;
    396396
    397397        /**
    … …  
    402402         * @var string
    403403         */
    404         var $signups;
     404        public $signups;
    405405
    406406        /**
    … …  
    411411         * @var string
    412412         */
    413         var $site;
     413        public $site;
    414414
    415415        /**
    … …  
    420420         * @var string
    421421         */
    422         var $sitecategories;
     422        public $sitecategories;
    423423
    424424        /**
    … …  
    429429         * @var string
    430430         */
    431         var $sitemeta;
     431        public $sitemeta;
    432432
    433433        /**
    … …  
    445445         * @var array
    446446         */
    447         var $field_types = array();
     447        public $field_types = array();
    448448
    449449        /**
    … …  
    454454         * @var string
    455455         */
    456         var $charset;
     456        public $charset;
    457457
    458458        /**
    … …  
    463463         * @var string
    464464         */
    465         var $collate;
     465        public $collate;
    466466
    467467        /**
    … …  
    517517         * @var string
    518518         */
    519         var $func_call;
     519        public $func_call;
    520520
    521521        /**
    … …  
    576576         * @param string $dbhost MySQL database host
    577577         */
    578         function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
     578        public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
    579579                register_shutdown_function( array( $this, '__destruct' ) );
    580580
    … …  
    615615         * @return bool true
    616616         */
    617         function __destruct() {
     617        public function __destruct() {
    618618                return true;
    619619        }
    … …  
    627627         * @return mixed The private member
    628628         */
    629         function __get( $name ) {
     629        public function __get( $name ) {
    630630                if ( 'col_info' == $name )
    631631                        $this->load_col_info();
    … …  
    642642         * @param mixed  $value The value to set
    643643         */
    644         function __set( $name, $value ) {
     644        public function __set( $name, $value ) {
    645645                $this->$name = $value;
    646646        }
    … …  
    655655         * @return bool If the member is set or not
    656656         */
    657         function __isset( $name ) {
     657        public function __isset( $name ) {
    658658                return isset( $this->$name );
    659659        }
    … …  
    666666         * @param string $name  The private member to unset
    667667         */
    668         function __unset( $name ) {
     668        public function __unset( $name ) {
    669669                unset( $this->$name );
    670670        }
    … …  
    675675         * @since 3.1.0
    676676         */
    677         function init_charset() {
     677        public function init_charset() {
    678678                if ( function_exists('is_multisite') && is_multisite() ) {
    679679                        $this->charset = 'utf8';
    … …  
    699699         * @param string   $collate The collation (optional)
    700700         */
    701         function set_charset( $dbh, $charset = null, $collate = null ) {
     701        public function set_charset( $dbh, $charset = null, $collate = null ) {
    702702                if ( ! isset( $charset ) )
    703703                        $charset = $this->charset;
    … …  
    737737         * @param array $modes Optional. A list of SQL modes to set.
    738738         */
    739         function set_sql_mode( $modes = array() ) {
     739        public function set_sql_mode( $modes = array() ) {
    740740                if ( empty( $modes ) ) {
    741741                        if ( $this->use_mysqli ) {
    … …  
    803803         * @return string|WP_Error Old prefix or WP_Error on error
    804804         */
    805         function set_prefix( $prefix, $set_table_names = true ) {
     805        public function set_prefix( $prefix, $set_table_names = true ) {
    806806
    807807                if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
    … …  
    842842         * @return string previous blog id
    843843         */
    844         function set_blog_id( $blog_id, $site_id = 0 ) {
     844        public function set_blog_id( $blog_id, $site_id = 0 ) {
    845845                if ( ! empty( $site_id ) )
    846846                        $this->siteid = $site_id;
    … …  
    868868         * @return string Blog prefix.
    869869         */
    870         function get_blog_prefix( $blog_id = null ) {
     870        public function get_blog_prefix( $blog_id = null ) {
    871871                if ( is_multisite() ) {
    872872                        if ( null === $blog_id )
    … …  
    910910         * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
    911911         */
    912         function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
     912        public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
    913913                switch ( $scope ) {
    914914                        case 'all' :
    … …  
    971971         * @return null Always null.
    972972         */
    973         function select( $db, $dbh = null ) {
     973        public function select( $db, $dbh = null ) {
    974974                if ( is_null($dbh) )
    975975                        $dbh = $this->dbh;
    … …  
    10801080         * @return mixed
    10811081         */
    1082         function escape( $data ) {
     1082        public function escape( $data ) {
    10831083                if ( func_num_args() === 1 && function_exists( '_deprecated_function' ) )
    10841084                        _deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' );
    … …  
    11051105         * @return void
    11061106         */
    1107         function escape_by_ref( &$string ) {
     1107        public function escape_by_ref( &$string ) {
    11081108                if ( ! is_float( $string ) )
    11091109                        $string = $this->_real_escape( $string );
    … …  
    11471147         *      if there was something to prepare
    11481148         */
    1149         function prepare( $query, $args ) {
     1149        public function prepare( $query, $args ) {
    11501150                if ( is_null( $query ) )
    11511151                        return;
    … …  
    11781178         * @return bool False if the showing of errors is disabled.
    11791179         */
    1180         function print_error( $str = '' ) {
     1180        public function print_error( $str = '' ) {
    11811181                global $EZSQL_ERROR;
    11821182
    … …  
    12381238         * @return bool Old value for showing errors.
    12391239         */
    1240         function show_errors( $show = true ) {
     1240        public function show_errors( $show = true ) {
    12411241                $errors = $this->show_errors;
    12421242                $this->show_errors = $show;
    … …  
    12541254         * @return bool Whether showing of errors was active
    12551255         */
    1256         function hide_errors() {
     1256        public function hide_errors() {
    12571257                $show = $this->show_errors;
    12581258                $this->show_errors = false;
    … …  
    12711271         * @return bool Old value
    12721272         */
    1273         function suppress_errors( $suppress = true ) {
     1273        public function suppress_errors( $suppress = true ) {
    12741274                $errors = $this->suppress_errors;
    12751275                $this->suppress_errors = (bool) $suppress;
    … …  
    12831283         * @return void
    12841284         */
    1285         function flush() {
     1285        public function flush() {
    12861286                $this->last_result = array();
    12871287                $this->col_info    = null;
    … …  
    13111311         * @return bool True with a successful connection, false on failure.
    13121312         */
    1313         function db_connect( $allow_bail = true ) {
     1313        public function db_connect( $allow_bail = true ) {
    13141314
    13151315                $this->is_mysql = true;
    … …  
    14261426         * @return bool True if the connection is up.
    14271427         */
    1428         function check_connection( $allow_bail = true ) {
     1428        public function check_connection( $allow_bail = true ) {
    14291429                if ( $this->use_mysqli ) {
    14301430                        if ( @mysqli_ping( $this->dbh ) ) {
    … …  
    14981498         * @return int|false Number of rows affected/selected or false on error
    14991499         */
    1500         function query( $query ) {
     1500        public function query( $query ) {
    15011501                if ( ! $this->ready )
    15021502                        return false;
    … …  
    16461646         * @return int|false The number of rows inserted, or false on error.
    16471647         */
    1648         function insert( $table, $data, $format = null ) {
     1648        public function insert( $table, $data, $format = null ) {
    16491649                return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' );
    16501650        }
    … …  
    16691669         * @return int|false The number of rows affected, or false on error.
    16701670         */
    1671         function replace( $table, $data, $format = null ) {
     1671        public function replace( $table, $data, $format = null ) {
    16721672                return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' );
    16731673        }
    … …  
    17321732         * @return int|false The number of rows updated, or false on error.
    17331733         */
    1734         function update( $table, $data, $where, $format = null, $where_format = null ) {
     1734        public function update( $table, $data, $where, $format = null, $where_format = null ) {
    17351735                if ( ! is_array( $data ) || ! is_array( $where ) )
    17361736                        return false;
    … …  
    17811781         * @return int|false The number of rows updated, or false on error.
    17821782         */
    1783         function delete( $table, $where, $where_format = null ) {
     1783        public function delete( $table, $where, $where_format = null ) {
    17841784                if ( ! is_array( $where ) )
    17851785                        return false;
    … …  
    18201820         * @return string|null Database query result (as string), or null on failure
    18211821         */
    1822         function get_var( $query = null, $x = 0, $y = 0 ) {
     1822        public function get_var( $query = null, $x = 0, $y = 0 ) {
    18231823                $this->func_call = "\$db->get_var(\"$query\", $x, $y)";
    18241824                if ( $query )
    … …  
    18471847         * @return mixed Database query result in format specified by $output or null on failure
    18481848         */
    1849         function get_row( $query = null, $output = OBJECT, $y = 0 ) {
     1849        public function get_row( $query = null, $output = OBJECT, $y = 0 ) {
    18501850                $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
    18511851                if ( $query )
    … …  
    18841884         * @return array Database query result. Array indexed from 0 by SQL result row number.
    18851885         */
    1886         function get_col( $query = null , $x = 0 ) {
     1886        public function get_col( $query = null , $x = 0 ) {
    18871887                if ( $query )
    18881888                        $this->query( $query );
    … …  
    19091909         * @return mixed Database query results
    19101910         */
    1911         function get_results( $query = null, $output = OBJECT ) {
     1911        public function get_results( $query = null, $output = OBJECT ) {
    19121912                $this->func_call = "\$db->get_results(\"$query\", $output)";
    19131913
    … …  
    19831983         * @return mixed Column Results
    19841984         */
    1985         function get_col_info( $info_type = 'name', $col_offset = -1 ) {
     1985        public function get_col_info( $info_type = 'name', $col_offset = -1 ) {
    19861986                $this->load_col_info();
    19871987
    … …  
    20082008         * @return true
    20092009         */
    2010         function timer_start() {
     2010        public function timer_start() {
    20112011                $this->time_start = microtime( true );
    20122012                return true;
    … …  
    20202020         * @return float Total time spent on the query, in seconds
    20212021         */
    2022         function timer_stop() {
     2022        public function timer_stop() {
    20232023                return ( microtime( true ) - $this->time_start );
    20242024        }
    … …  
    20352035         * @return false|void
    20362036         */
    2037         function bail( $message, $error_code = '500' ) {
     2037        public function bail( $message, $error_code = '500' ) {
    20382038                if ( !$this->show_errors ) {
    20392039                        if ( class_exists( 'WP_Error' ) )
    … …  
    20552055         * @return WP_Error
    20562056         */
    2057         function check_database_version() {
     2057        public function check_database_version() {
    20582058                global $wp_version, $required_mysql_version;
    20592059                // Make sure the server has the required MySQL version
    … …  
    20732073         * @return bool True if collation is supported, false if version does not
    20742074         */
    2075         function supports_collation() {
     2075        public function supports_collation() {
    20762076                _deprecated_function( __FUNCTION__, '3.5', 'wpdb::has_cap( \'collation\' )' );
    20772077                return $this->has_cap( 'collation' );
    … …  
    21052105         * @return bool
    21062106         */
    2107         function has_cap( $db_cap ) {
     2107        public function has_cap( $db_cap ) {
    21082108                $version = $this->db_version();
    21092109
    … …  
    21302130         * @return string The name of the calling function
    21312131         */
    2132         function get_caller() {
     2132        public function get_caller() {
    21332133                return wp_debug_backtrace_summary( __CLASS__ );
    21342134        }
    … …  
    21412141         * @return false|string false on failure, version number on success
    21422142         */
    2143         function db_version() {
     2143        public function db_version() {
    21442144                if ( $this->use_mysqli ) {
    21452145                        $server_info = mysqli_get_server_info( $this->dbh );
Note: See TracChangeset for help on using the changeset viewer.