[wp-trac] [WordPress Trac] #33697: utf8mb4 conversion runs on "term_relationships" when perhaps it should not
WordPress Trac
noreply at wordpress.org
Wed Sep 2 23:54:14 UTC 2015
#33697: utf8mb4 conversion runs on "term_relationships" when perhaps it should not
--------------------------+-----------------------------
Reporter: tollmanz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: 4.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
When the `term_relationships` table is passed to
`maybe_convert_table_to_utf8mb4()`, it will always end in the `ALTER
TABLE` command. As far as I can tell, there is no point in running the
update on this table since it only contains `BIGINT` and `INT` columns.
Additionally, one of the exit early conditions is, `'utf8' !== $charset &&
'utf8mb4' !== $charset`, which all columns in `term_relationships` would
match, but this statement is never reached for the table.
In this snippet:
{{{
foreach ( $results as $column ) {
if ( $column->Collation ) {
list( $charset ) = explode( '_',
$column->Collation );
$charset = strtolower( $charset );
if ( 'utf8' !== $charset && 'utf8mb4' !== $charset
) {
// Don't upgrade tables that have non-utf8
columns.
return false;
}
}
}
}}}
the `if ( $column->Collation )` condition prevents all of the columns in
`term_relationships` from entering the condition. Since
`$column->Collation === NULL` for each `term_relationship`, the exit
condition will never be reached.
Further on, this snippet appears:
{{{
$table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'"
);
if ( ! $table_details ) {
return false;
}
list( $table_charset ) = explode( '_', $table_details->Collation
);
$table_charset = strtolower( $table_charset );
if ( 'utf8mb4' === $table_charset ) {
return true;
}
}}}
I cannot seem to get `$table_details->Collation` to be anything other than
`utf8_general_ci`, even after running the `utf8mb4` alter query (which
does make sense). Because the `if ( 'utf8mb4' === $table_charset )` is not
true, the function does not exit, and the alter query executes.
Admittedly, I don't think this is a big deal, but perhaps has the ability
to become an annoying bug in the future. It seems to me like an additional
check could be helpful here. The check would look to see if all columns in
a table have a `NULL` value for `Collation`, the function should exit
early.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33697>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list