From 5af5737a6de2da256d4382953a3f9b6a1c43f5f1 Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Thu, 3 Nov 2016 16:13:17 -0400 Subject: [PATCH] Fix #811 - fetch and show emoji icons --- daos/mysql/Items.php | 2 +- daos/mysql/Statements.php | 4 ++-- daos/mysql/Tags.php | 2 +- libs/f3/db/sql.php | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/daos/mysql/Items.php b/daos/mysql/Items.php index 3f4fe1f542..be034bfe52 100644 --- a/daos/mysql/Items.php +++ b/daos/mysql/Items.php @@ -219,7 +219,7 @@ public function get($options = array()) { if(isset($options['tag']) && strlen($options['tag'])>0) { $params[':tag'] = array( "%,".$options['tag'].",%" , \PDO::PARAM_STR ); if ( \F3::get( 'db_type' ) == 'mysql' ) { - $where .= " AND ( CONCAT( ',' , sources.tags , ',' ) LIKE _utf8 :tag COLLATE utf8_bin ) "; + $where .= " AND ( CONCAT( ',' , sources.tags , ',' ) LIKE _utf8mb4 :tag COLLATE utf8mb4_general_ci ) "; } else { $where .= " AND ( (',' || sources.tags || ',') LIKE :tag ) "; } diff --git a/daos/mysql/Statements.php b/daos/mysql/Statements.php index abb87637a7..62f2c35a8e 100644 --- a/daos/mysql/Statements.php +++ b/daos/mysql/Statements.php @@ -80,8 +80,8 @@ public static function isFalse($column) { */ public static function csvRowMatches($column, $value) { if( $value[0] == ':' ) - $value = "_utf8 $value"; + $value = "_utf8mb4 $value"; - return "CONCAT(',', $column, ',') LIKE CONCAT('%,', $value, ',%') COLLATE utf8_bin"; + return "CONCAT(',', $column, ',') LIKE CONCAT('%,', $value, ',%') COLLATE utf8mb4_general_ci"; } } diff --git a/daos/mysql/Tags.php b/daos/mysql/Tags.php index a796f3bbb5..48f3a297b2 100644 --- a/daos/mysql/Tags.php +++ b/daos/mysql/Tags.php @@ -130,7 +130,7 @@ private function isColorUsed($color) { */ public function hasTag($tag) { if ( \F3::get( 'db_type' ) == 'mysql' ) { - $where = 'WHERE tag = _utf8 :tag COLLATE utf8_bin'; + $where = 'WHERE tag = _utf8mb4 :tag COLLATE utf8mb4_general_ci'; } else { $where = 'WHERE tag=:tag'; } diff --git a/libs/f3/db/sql.php b/libs/f3/db/sql.php index 6008944641..100d8a1fa5 100644 --- a/libs/f3/db/sql.php +++ b/libs/f3/db/sql.php @@ -461,8 +461,7 @@ function __construct($dsn,$user=NULL,$pw=NULL,array $options=NULL) { if (!$options) $options=array(); if (isset($parts[0]) && strstr($parts[0],':',TRUE)=='mysql') - $options+=array(\PDO::MYSQL_ATTR_INIT_COMMAND=>'SET NAMES '. - strtolower(str_replace('-','',$fw->get('ENCODING'))).';'); + $options+=array(\PDO::MYSQL_ATTR_INIT_COMMAND=>'SET NAMES utf8mb4;'); $this->pdo=new \PDO($dsn,$user,$pw,$options); $this->engine=$this->pdo->getattribute(\PDO::ATTR_DRIVER_NAME); }