Parcourir la source

Feature #272 - An encoding related logucal correction within the database class.

Ivan Tcholakov il y a 15 ans
Parent
commit
0c8e94a4d6
1 fichiers modifiés avec 7 ajouts et 5 suppressions
  1. 7 5
      main/inc/lib/database.lib.php

+ 7 - 5
main/inc/lib/database.lib.php

@@ -824,7 +824,12 @@ class Database {
 	public static function is_encoding_supported($encoding) {
 		static $supported = array();
 		if (!isset($supported[$encoding])) {
-			$supported[$encoding] = strlen(self::to_db_encoding($encoding)) > 0;
+			$supported[$encoding] = false;
+			if (strlen($db_encoding = self::to_db_encoding($encoding)) > 0) {
+				if (self::num_rows(self::query("SHOW CHARACTER SET WHERE `Charset` =  '".$db_encoding."';", __FILE__, __LINE__)) > 0) {
+					$supported[$encoding] = true;
+				}
+			}
 		}
 		return $supported[$encoding];
 	}
@@ -883,10 +888,7 @@ class Database {
 			$encoding_map = & self::get_db_encoding_map();
 			foreach ($encoding_map as $key => $value) {
 				if (api_equal_encodings($encoding, $key)) {
-					// Check whether the encoding is supported by the server.
-					if (self::num_rows(self::query("SHOW CHARACTER SET WHERE `Charset` =  '".$value."';", __FILE__, __LINE__)) > 0) {
-						$result[$encoding] = $value;
-					}
+					$result[$encoding] = $value;
 					break;
 				}
 			}