Ticket #25282: 25282.diff
File 25282.diff, 6.5 KB (added by , 11 years ago) |
---|
-
src/wp-includes/post.php
3957 3957 3958 3958 $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID, 3959 3959 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'post_title' => '', 3960 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 3960 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '', 3961 3961 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => ''); 3962 3962 3963 3963 $object = wp_parse_args($object, $defaults); … … 4029 4029 else 4030 4030 $to_ping = ''; 4031 4031 4032 if ( isset( $post_parent) )4032 if ( isset( $post_parent ) ) 4033 4033 $post_parent = (int) $post_parent; 4034 4034 else 4035 4035 $post_parent = 0; -
src/wp-includes/wp-db.php
637 637 if ( ! isset( $collate ) ) 638 638 $collate = $this->collate; 639 639 if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) { 640 if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) { 641 mysql_set_charset( $charset, $dbh ); 642 } else { 643 $query = $this->prepare( 'SET NAMES %s', $charset ); 644 if ( ! empty( $collate ) ) 645 $query .= $this->prepare( ' COLLATE %s', $collate ); 646 mysql_query( $query, $dbh ); 647 } 640 $query = $this->prepare( 'SET NAMES %s', $charset ); 641 if ( ! empty( $collate ) ) 642 $query .= $this->prepare( ' COLLATE %s', $collate ); 643 mysqli_query( $dbh, $query ); 648 644 } 649 645 } 650 646 … … 830 826 if ( is_null($dbh) ) 831 827 $dbh = $this->dbh; 832 828 833 if ( ! @mysql_select_db( $db, $dbh) ) {829 if ( ! @mysqli_select_db( $dbh, $db ) ) { 834 830 $this->ready = false; 835 831 wp_load_translations_early(); 836 832 $this->bail( sprintf( __( '<h1>Can’t select database</h1> … … 866 862 } 867 863 868 864 /** 869 * Real escape, using mysql _real_escape_string()865 * Real escape, using mysqli_real_escape_string() 870 866 * 871 * @see mysql_real _escape_string()867 * @see mysql_reali_escape_string() 872 868 * @since 2.8.0 873 869 * @access private 874 870 * … … 877 873 */ 878 874 function _real_escape( $string ) { 879 875 if ( $this->dbh ) 880 return mysql _real_escape_string( $string, $this->dbh);876 return mysqli_real_escape_string( $this->dbh, $string ); 881 877 882 878 $class = get_class( $this ); 883 879 _doing_it_wrong( $class, "$class must set a database connection for use with escaping.", E_USER_NOTICE ); … … 1019 1015 global $EZSQL_ERROR; 1020 1016 1021 1017 if ( !$str ) 1022 $str = mysql _error( $this->dbh );1018 $str = mysqli_error( $this->dbh ); 1023 1019 $EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str ); 1024 1020 1025 1021 if ( $this->suppress_errors ) … … 1123 1119 $this->last_error = ''; 1124 1120 1125 1121 if ( is_resource( $this->result ) ) 1126 mysql _free_result( $this->result );1122 mysqli_free_result( $this->result ); 1127 1123 } 1128 1124 1129 1125 /** … … 1135 1131 1136 1132 $this->is_mysql = true; 1137 1133 1138 $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true;1139 1134 $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; 1140 1135 1141 1136 if ( WP_DEBUG ) { 1142 $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); 1137 $this->dbh = mysqli_init(); 1138 mysqli_real_connect( $this->dbh, $this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname, null, null, $client_flags ); 1143 1139 } else { 1144 $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); 1140 $this->dbh = @mysqli_init(); 1141 @mysql_real_connect( $this->dbh, $this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname, null, null, $client_flags ); 1145 1142 } 1146 1143 1147 1144 if ( !$this->dbh ) { … … 1202 1199 if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) 1203 1200 $this->timer_start(); 1204 1201 1205 $this->result = @mysql _query( $query, $this->dbh);1202 $this->result = @mysqli_query( $this->dbh, $query ); 1206 1203 $this->num_queries++; 1207 1204 1208 1205 if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) 1209 1206 $this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() ); 1210 1207 1211 1208 // If there is an error then take note of it.. 1212 if ( $this->last_error = mysql _error( $this->dbh ) ) {1209 if ( $this->last_error = mysqli_error( $this->dbh ) ) { 1213 1210 // Clear insert_id on a subsequent failed insert. 1214 1211 if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) ) 1215 1212 $this->insert_id = 0; … … 1221 1218 if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) { 1222 1219 $return_val = $this->result; 1223 1220 } elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) { 1224 $this->rows_affected = mysql _affected_rows( $this->dbh );1221 $this->rows_affected = mysqli_affected_rows( $this->dbh ); 1225 1222 // Take note of the insert_id 1226 1223 if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { 1227 $this->insert_id = mysql _insert_id($this->dbh);1224 $this->insert_id = mysqli_insert_id( $this->dbh ); 1228 1225 } 1229 1226 // Return number of rows affected 1230 1227 $return_val = $this->rows_affected; 1231 1228 } else { 1232 1229 $num_rows = 0; 1233 while ( $row = @mysql _fetch_object( $this->result ) ) {1230 while ( $row = @mysqli_fetch_object( $this->result ) ) { 1234 1231 $this->last_result[$num_rows] = $row; 1235 1232 $num_rows++; 1236 1233 } … … 1574 1571 if ( $this->col_info ) 1575 1572 return; 1576 1573 1577 for ( $i = 0; $i < @mysql _num_fields( $this->result ); $i++ ) {1578 $this->col_info[ $i ] = @mysql _fetch_field( $this->result, $i);1574 for ( $i = 0; $i < @mysqli_num_fields( $this->result ); $i++ ) { 1575 $this->col_info[ $i ] = @mysqli_fetch_field( $this->result ); 1579 1576 } 1580 1577 } 1581 1578 … … 1747 1744 * @return false|string false on failure, version number on success 1748 1745 */ 1749 1746 function db_version() { 1750 return preg_replace( '/[^0-9.].*/', '', mysql _get_server_info( $this->dbh ) );1747 return preg_replace( '/[^0-9.].*/', '', mysqli_get_server_info( $this->dbh ) ); 1751 1748 } 1752 1749 } -
tests/phpunit/includes/factory.php
122 122 'comment_author' => new WP_UnitTest_Generator_Sequence( 'Commenter %s' ), 123 123 'comment_author_url' => new WP_UnitTest_Generator_Sequence( 'http://example.com/%s/' ), 124 124 'comment_approved' => 1, 125 'comment_content' => 'This is a comment' 125 126 ); 126 127 } 127 128