From: Zach Copley Date: Thu, 18 Jun 2009 19:19:19 +0000 (+0000) Subject: Make sure we have a DB connection before setting its charset X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e0fb15c185f4ca81743937c27557c9402ba59071;p=quix0rs-gnu-social.git Make sure we have a DB connection before setting its charset --- diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 33ac70dd04..f945e94ff3 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -242,13 +242,16 @@ class Memcached_DataObject extends DB_DataObject if (common_config('db', 'type') == 'mysql' && common_config('db', 'utf8')) { $conn = $DB->connection; - if ($DB instanceof DB_mysqli) { - mysqli_set_charset($conn, 'utf8'); - } else if ($DB instanceof DB_mysql) { - mysql_set_charset('utf8', $conn); + if (!empty($conn)) { + if ($DB instanceof DB_mysqli) { + mysqli_set_charset($conn, 'utf8'); + } else if ($DB instanceof DB_mysql) { + mysql_set_charset('utf8', $conn); + } } } } return $result; } + }