Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch back to utf8 for LCache tables #149

Merged
merged 2 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/phpunit/test-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public function test_normalize_address_key() {
$this->assertEquals( 255, strlen( $ascii_over_max_address->serialize() ) );
}

public function test_save_emoji_to_cache() {
$this->cache->set( 'foo', '❤️' );
// Re-initialize the cache.
$this->cache =& $this->init_cache();
$this->assertEquals( '❤️', $this->cache->get( 'foo' ) );
}

public function test_loaded() {
$this->assertTrue( WP_LCACHE_OBJECT_CACHE );
}
Expand Down Expand Up @@ -1003,7 +1010,7 @@ public function test_invalid_schema_produces_warning() {
$this->altered_value_column = true;
$ret = $wpdb->get_results( "SHOW CREATE TABLE `{$table_prefix}lcache_events`" );
// @codingStandardsIgnoreEnd
$this->assertContains( '`value` varchar(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL,', $ret[0]->{'Create Table'} );
$this->assertContains( '`value` varchar(2) DEFAULT NULL,', $ret[0]->{'Create Table'} );
$this->cache->set( 'foo', 'basjkfsdfsdksd' );
}

Expand Down
19 changes: 5 additions & 14 deletions wp-lcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP LCache
* Plugin URI: https://github.com/pantheon-systems/wp-lcache/
* Description: Supercharge your WP Object Cache with LCache, a persistent, performant, and multi-layer cache library.
* Version: 0.6.0
* Version: 0.6.1-alpha
* Author: Pantheon, Daniel Bachhuber
* Author URI: https://pantheon.io/
* License: GPL-2.0
Expand Down Expand Up @@ -34,15 +34,6 @@
function wp_lcache_initialize_database_schema() {
global $wpdb;

$charset_collate = $wpdb->get_charset_collate();
// Barracuda needs ROW_FORMAT=DYNAMIC when using utf8mb4
if ( false !== stripos( $charset_collate, 'utf8mb4' ) ) {
$innodb_file_format = $wpdb->get_var( 'SELECT @@innodb_file_format' );
if ( false !== stripos( $innodb_file_format, 'Barracuda' ) ) {
$charset_collate .= ' ROW_FORMAT=DYNAMIC';
}
}

// @codingStandardsIgnoreStart
$events_table = $GLOBALS['table_prefix'] . 'lcache_events';
$wpdb->query( "CREATE TABLE IF NOT EXISTS `{$events_table}` (
Expand All @@ -56,15 +47,15 @@ function wp_lcache_initialize_database_schema() {
UNIQUE KEY `event_id` (`event_id`),
KEY `expiration` (`expiration`),
KEY `lookup_miss` (`address`,`event_id`)
) {$charset_collate};" );
) ENGINE=InnoDB DEFAULT CHARSET=utf8;" );

$tags_table = $GLOBALS['table_prefix'] . 'lcache_tags';
$wpdb->query( "CREATE TABLE IF NOT EXISTS `{$tags_table}` (
`tag` varchar(191) NOT NULL DEFAULT '',
`address` varchar(191) NOT NULL DEFAULT '',
`tag` varchar(255) NOT NULL DEFAULT '',
`address` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`tag`,`address`),
KEY `rewritten_entry` (`address`)
) {$charset_collate};" );
) ENGINE=InnoDB DEFAULT CHARSET=utf8;" );
// @codingStandardsIgnoreEnd
}

Expand Down