Changeset 31349 for trunk/src/wp-includes/wp-db.php
- Timestamp:
- 02/06/2015 04:50:19 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/wp-db.php
r31294 r31349 625 625 } 626 626 627 $this->init_charset();628 629 627 $this->dbuser = $dbuser; 630 628 $this->dbpassword = $dbpassword; … … 718 716 if ( function_exists('is_multisite') && is_multisite() ) { 719 717 $this->charset = 'utf8'; 720 if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) 718 if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) { 721 719 $this->collate = DB_COLLATE; 722 else720 } else { 723 721 $this->collate = 'utf8_general_ci'; 722 } 724 723 } elseif ( defined( 'DB_COLLATE' ) ) { 725 724 $this->collate = DB_COLLATE; 726 725 } 727 726 728 if ( defined( 'DB_CHARSET' ) ) 727 if ( defined( 'DB_CHARSET' ) ) { 729 728 $this->charset = DB_CHARSET; 729 } 730 731 if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) 732 || ( empty( $this->dbh ) || ! ( $this->dbh instanceof mysqli ) ) ) { 733 return; 734 } 735 736 if ( 'utf8' === $this->charset && $this->has_cap( 'utf8mb4' ) ) { 737 $this->charset = 'utf8mb4'; 738 } 739 740 if ( 'utf8mb4' === $this->charset && ( ! $this->collate || stripos( $this->collate, 'utf8_' ) === 0 ) ) { 741 $this->collate = 'utf8mb4_unicode_ci'; 742 } 730 743 } 731 744 … … 1477 1490 return false; 1478 1491 } elseif ( $this->dbh ) { 1492 if ( ! $this->has_connected ) { 1493 $this->init_charset(); 1494 } 1495 1479 1496 $this->has_connected = true; 1497 1480 1498 $this->set_charset( $this->dbh ); 1499 1481 1500 $this->ready = true; 1482 1501 $this->set_sql_mode(); … … 2250 2269 * 2251 2270 * @since 4.2.0 2252 * @access p rotected2271 * @access public 2253 2272 * 2254 2273 * @param string $table Table name. … … 2257 2276 * character set. {@see WP_Error} object if there was an error. 2258 2277 */ 2259 p rotectedfunction get_col_charset( $table, $column ) {2278 public function get_col_charset( $table, $column ) { 2260 2279 $tablekey = strtolower( $table ); 2261 2280 $columnkey = strtolower( $column ); … … 2357 2376 'ujis' => 'EUC-JP', 2358 2377 'utf32' => 'UTF-32', 2359 'utf8mb4' => 'UTF-8',2360 2378 ); 2361 2379 … … 2392 2410 } 2393 2411 2394 // utf8 (mb3)can be handled by regex, which is a bunch faster than a DB lookup.2395 if ( 'utf8' === $charset || 'utf8mb3' === $charset ) {2412 // utf8 can be handled by regex, which is a bunch faster than a DB lookup. 2413 if ( 'utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset ) { 2396 2414 $regex = '/ 2397 2415 ( … … 2401 2419 | [\xE1-\xEC][\x80-\xBF]{2} 2402 2420 | \xED[\x80-\x9F][\x80-\xBF] 2403 | [\xEE-\xEF][\x80-\xBF]{2} 2404 ){1,50} # ...one or more times 2421 | [\xEE-\xEF][\x80-\xBF]{2}'; 2422 2423 if ( 'utf8mb4' === $charset) { 2424 $regex .= ' 2425 | \xF0[\x90-\xBF][\x80-\xBF]{2} # four-byte sequences 11110xxx 10xxxxxx * 3 2426 | [\xF1-\xF3][\x80-\xBF]{3} 2427 | \xF4[\x80-\x8F][\x80-\xBF]{2} 2428 '; 2429 } 2430 2431 $regex .= '){1,50} # ...one or more times 2405 2432 ) 2406 2433 | . # anything else
Note: See TracChangeset
for help on using the changeset viewer.