Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14088157
D10604.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10604.diff
View Options
diff --git a/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
--- a/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
+++ b/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
@@ -20,7 +20,7 @@
abstract protected function freeResult($result);
public function __construct(array $configuration) {
- $this->configuration = $configuration;
+ $this->configuration = $configuration;
}
public function __clone() {
@@ -324,16 +324,32 @@
* can lead to data loss and security problems.
*/
protected function validateUTF8String($string) {
- if (phutil_is_utf8_with_only_bmp_characters($string)) {
- return;
- }
+ // TODO: Make this `true` eventually, once we make storage adjustment
+ // mandatory. For now, you can set it to `true` to test things.
+ $has_utf8mb4 = false;
+
+ if ($has_utf8mb4) {
+ if (phutil_is_utf8($string)) {
+ return;
+ }
- throw new AphrontCharacterSetQueryException(
- pht(
- 'Attempting to construct a query containing characters outside of '.
- 'the Unicode Basic Multilingual Plane. MySQL will silently truncate '.
- 'this data if it is inserted into a `utf8` column. Use the `%%B` '.
- 'conversion to escape binary strings data.'));
+ throw new AphrontCharacterSetQueryException(
+ pht(
+ 'Attempting to construct a query using a non-utf8 string when '.
+ 'utf8 is expected. Use the `%%B` conversion to escape binary '.
+ 'strings data.'));
+ } else {
+ if (phutil_is_utf8_with_only_bmp_characters($string)) {
+ return;
+ }
+
+ throw new AphrontCharacterSetQueryException(
+ pht(
+ 'Attempting to construct a query containing characters outside of '.
+ 'the Unicode Basic Multilingual Plane. MySQL will silently truncate '.
+ 'this data if it is inserted into a `utf8` column. Use the `%%B` '.
+ 'conversion to escape binary strings data.'));
+ }
}
}
diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
--- a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
+++ b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
@@ -72,7 +72,10 @@
}
}
- mysql_set_charset('utf8', $conn);
+ $ok = mysql_set_charset('utf8mb4', $conn);
+ if (!$ok) {
+ mysql_set_charset('utf8', $conn);
+ }
return $conn;
}
diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php
--- a/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php
+++ b/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php
@@ -67,7 +67,10 @@
"#{$errno}: {$error}.", $errno);
}
- $conn->set_charset('utf8');
+ $ok = $conn->set_charset('utf8mb4');
+ if (!$ok) {
+ $ok = $conn->set_charset('utf8');
+ }
return $conn;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 1:48 AM (20 h, 48 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6784604
Default Alt Text
D10604.diff (3 KB)
Attached To
Mode
D10604: Make libphutil compatible with utf8mb4
Attached
Detach File
Event Timeline
Log In to Comment