Make WordPress Core

Changeset 38581 for branches/4.6/src


Ignore:
Timestamp:
09/08/2016 11:53:25 PM (10 years ago)
Author:
pento
Message:

Database: Fall back to utf8 when utf8mb4 isn't supported.

Sometimes, DB_CHARSET will be set to utf8mb4, even if the current setup doesn't support utf8mb4. After [38442], this can cause significant character set failures, causing the connection to fall back to latin1.

Instead of doing this, we now check that the connection supports utf8mb4 before trying to use it, and fall back to utf8 when we need to.

Merge of [38580] to the 4.6 branch.
Fixes #37982.

Location:
branches/4.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/wp-db.php

    r38442 r38581  
    778778        if ( 'utf8' === $charset && $this->has_cap( 'utf8mb4' ) ) {
    779779            $charset = 'utf8mb4';
     780        }
     781
     782        if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) {
     783            $charset = 'utf8';
     784            $collate = str_replace( 'utf8mb4_', 'utf8_', $collate );
    780785        }
    781786
Note: See TracChangeset for help on using the changeset viewer.