فهرست منبع

Feature #272 - Speeding up the function api_get_system_encoding().

Ivan Tcholakov 15 سال پیش
والد
کامیت
3fc29d3e55
1فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 10 6
      main/inc/lib/internationalization.lib.php

+ 10 - 6
main/inc/lib/internationalization.lib.php

@@ -3386,13 +3386,17 @@ function api_is_latin1($encoding, $strict = false) {
  * reason both attempts fail, then the libraly's internal value will be returned.
  * reason both attempts fail, then the libraly's internal value will be returned.
  */
  */
 function api_get_system_encoding() {
 function api_get_system_encoding() {
-	$system_encoding = api_get_setting('platform_charset');
-	if (empty($system_encoding)) {
-		global $charset;
-		if (empty($charset)) {
-			return _api_mb_internal_encoding();
+	static $system_encoding;
+	if (!isset($system_encoding)) {
+		$encoding_setting = api_get_setting('platform_charset');
+		if (empty($encoding_setting)) {
+			global $charset;
+			if (empty($charset)) {
+				return _api_mb_internal_encoding();
+			}
+			return $charset;
 		}
 		}
-		return $charset;
+		$system_encoding = $encoding_setting;
 	}
 	}
 	return $system_encoding;
 	return $system_encoding;
 }
 }