Make WordPress Core

Ticket #37982: 37982.2.diff

File 37982.2.diff, 1.3 KB (added by pento, 8 years ago)
  • src/wp-includes/wp-db.php

     
    779779                        $charset = 'utf8mb4';
    780780                }
    781781
     782                if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) {
     783                        $charset = 'utf8';
     784                        $collate = str_replace( 'utf8mb4_', 'utf8_', $collate );
     785                }
     786
    782787                if ( 'utf8mb4' === $charset ) {
    783788                        // _general_ is outdated, so we can upgrade it to _unicode_, instead.
    784789                        if ( ! $collate || 'utf8_general_ci' === $collate ) {
  • tests/phpunit/tests/db.php

     
    10311031
    10321032                $this->assertSame( 'utf8mb4_swedish_ci', $result['collate'] );
    10331033        }
     1034
     1035        /**
     1036         * @ticket 37982
     1037         */
     1038        function test_charset_switched_to_utf8() {
     1039                global $wpdb;
     1040
     1041                if ( $wpdb->has_cap( 'utf8mb4' ) ) {
     1042                        $this->markTestSkipped( 'This test requires utf8mb4 to not be supported.' );
     1043                }
     1044
     1045                $charset = 'utf8mb4';
     1046                $collate = 'utf8mb4_general_ci';
     1047
     1048                $result = $wpdb->determine_charset( $charset, $collate );
     1049
     1050                $this->assertSame( 'utf8', $result['charset'] );
     1051                $this->assertSame( 'utf8_general_ci', $result['collate'] );
     1052        }
    10341053}