Differential D10604 Diff 25480 src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
Show All 14 Lines | abstract class AphrontBaseMySQLDatabaseConnection | ||||
abstract protected function rawQueries(array $raw_queries); | abstract protected function rawQueries(array $raw_queries); | ||||
abstract protected function fetchAssoc($result); | abstract protected function fetchAssoc($result); | ||||
abstract protected function getErrorCode($connection); | abstract protected function getErrorCode($connection); | ||||
abstract protected function getErrorDescription($connection); | abstract protected function getErrorDescription($connection); | ||||
abstract protected function closeConnection(); | abstract protected function closeConnection(); | ||||
abstract protected function freeResult($result); | abstract protected function freeResult($result); | ||||
public function __construct(array $configuration) { | public function __construct(array $configuration) { | ||||
$this->configuration = $configuration; | $this->configuration = $configuration; | ||||
} | } | ||||
public function __clone() { | public function __clone() { | ||||
$this->establishConnection(); | $this->establishConnection(); | ||||
} | } | ||||
public function close() { | public function close() { | ||||
if ($this->lastResult) { | if ($this->lastResult) { | ||||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | abstract class AphrontBaseMySQLDatabaseConnection | ||||
} | } | ||||
/** | /** | ||||
* Check inserts for characters outside of the BMP. Even with the strictest | * Check inserts for characters outside of the BMP. Even with the strictest | ||||
* settings, MySQL will silently truncate data when it encounters these, which | * settings, MySQL will silently truncate data when it encounters these, which | ||||
* can lead to data loss and security problems. | * can lead to data loss and security problems. | ||||
*/ | */ | ||||
protected function validateUTF8String($string) { | protected function validateUTF8String($string) { | ||||
// 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 using a non-utf8 string when '. | |||||
'utf8 is expected. Use the `%%B` conversion to escape binary '. | |||||
btrahan: there's an extra % | |||||
Not Done Inline ActionsThis is intentional, since we don't want pht() to interpret %B as a conversion. epriestley: This is intentional, since we don't want `pht()` to interpret `%B` as a conversion. | |||||
Not Done Inline Actionsoh, whoops, righto btrahan: oh, whoops, righto | |||||
'strings data.')); | |||||
} else { | |||||
if (phutil_is_utf8_with_only_bmp_characters($string)) { | if (phutil_is_utf8_with_only_bmp_characters($string)) { | ||||
return; | return; | ||||
} | } | ||||
throw new AphrontCharacterSetQueryException( | throw new AphrontCharacterSetQueryException( | ||||
pht( | pht( | ||||
'Attempting to construct a query containing characters outside of '. | 'Attempting to construct a query containing characters outside of '. | ||||
'the Unicode Basic Multilingual Plane. MySQL will silently truncate '. | 'the Unicode Basic Multilingual Plane. MySQL will silently truncate '. | ||||
'this data if it is inserted into a `utf8` column. Use the `%%B` '. | 'this data if it is inserted into a `utf8` column. Use the `%%B` '. | ||||
'conversion to escape binary strings data.')); | 'conversion to escape binary strings data.')); | ||||
} | } | ||||
} | |||||
} | } |
there's an extra %