Index: include/data_cache.php
@@ -110,11 +110,52 @@
 function func_dc_languages($code) {
 	global $sql_tbl;
 
-	$languages = func_query_hash("SELECT $sql_tbl[language_codes].*, IFNULL(lng_l.value, $sql_tbl[language_codes].language) as language, $sql_tbl[images_G].image_path, $sql_tbl[images_G].image_x, $sql_tbl[images_G].image_y FROM $sql_tbl[languages], $sql_tbl[language_codes] LEFT JOIN $sql_tbl[languages] as lng_l ON lng_l.code = '$code' AND lng_l.name = CONCAT('language_', $sql_tbl[language_codes].code) LEFT JOIN $sql_tbl[images_G] ON $sql_tbl[images_G].id = $sql_tbl[language_codes].lngid WHERE $sql_tbl[languages].code = $sql_tbl[language_codes].code GROUP BY $sql_tbl[languages].code ORDER BY language", 'code', false, false);
+    $_codes = func_data_cache_get('sql', 
+        array(
+            "md5" => "DISTINCT_code_FROM_languages",
+            "query" => "SELECT DISTINCT code FROM $sql_tbl[languages]",
+            "type" => "column"
+        )
+    );
+
+    $languages_codes = implode("', '", $_codes);
+
+    if (defined('X_MYSQL41_COMP_MODE')) {
+        $languages = func_query_hash("
+                SELECT tmp_lng.*, IFNULL(lng_l.value, tmp_lng.language) AS language,
+                       $sql_tbl[images_G].image_path, $sql_tbl[images_G].image_x, $sql_tbl[images_G].image_y
+                  FROM (
+                      SELECT DISTINCT $sql_tbl[language_codes].*, CONCAT('language_', code) AS _language_code
+                        FROM $sql_tbl[language_codes]
+                       WHERE code IN ('$languages_codes')
+                 ) AS tmp_lng
+                  LEFT JOIN $sql_tbl[languages] AS lng_l
+                    ON lng_l.code               = '$code'
+                   AND lng_l.name               = tmp_lng._language_code
+                  LEFT JOIN $sql_tbl[images_G]
+                    ON $sql_tbl[images_G].id    = tmp_lng.lngid
+                 ORDER BY language", 'code', false, false);
+    } else {
+        $languages = func_query_hash("
+                SELECT $sql_tbl[language_codes].*, IFNULL(lng_l.value, $sql_tbl[language_codes].language) as
+                       language, $sql_tbl[images_G].image_path, $sql_tbl[images_G].image_x,
+                       $sql_tbl[images_G].image_y
+                  FROM $sql_tbl[languages], $sql_tbl[language_codes]
+                  LEFT JOIN $sql_tbl[languages] as lng_l
+                    ON lng_l.code               = '$code'
+                   AND lng_l.name               = CONCAT('language_', $sql_tbl[language_codes].code)
+                  LEFT JOIN $sql_tbl[images_G]
+                    ON $sql_tbl[images_G].id    = $sql_tbl[language_codes].lngid
+                 WHERE $sql_tbl[languages].code = $sql_tbl[language_codes].code
+                 GROUP BY $sql_tbl[languages].code
+                 ORDER BY language", 'code', false, false);
+    }                             
 
 	if (!empty($languages)) {
 		foreach ($languages as $k => $v) {
 			$languages[$k]['code'] = $k;
+			unset($languages[$k]['_language_code']);
+
 			if (is_null($v['image_path']))
 				unset($languages[$k]['image_path']);
 		}	
@@ -147,6 +188,9 @@
 		case 'first_cell':
 			return func_query_first_cell($query);
 
+        case 'column':
+            return func_query_column($query);
+
 		default:
 			return func_query($query);
 	}

Index: include/func/func.core.php
@@ -1611,7 +1611,8 @@
 #
 # Clear data cache
 #
-function func_data_cache_clear($name = false) {
+function func_data_cache_clear($name = false, $add_name = '') 
+{
 	global $data_caches, $var_dirs, $xcart_dir;
 
     if ($name !== false && (!isset($data_caches[$name]) || empty($data_caches[$name]['func']) || !function_exists($data_caches[$name]['func'])))
@@ -1620,6 +1621,14 @@
     $path = $var_dirs["cache"];
 
 	$dir = opendir($path);
+
+    if (
+        is_string($name)
+        && is_scalar($add_name)
+    ) {
+        $name .= '.' . (string)$add_name;
+    }
+
 	if (!$dir)
 		return false;
 
Index: admin/languages.php
@@ -126,6 +126,7 @@
 					);
 				}
 			}
+			func_data_cache_clear('sql', 'DISTINCT_code_FROM_languages.column');
 		}
 
 		if ($topic == 'Languages') {
@@ -182,6 +183,7 @@
 					true
 				);
 			}
+			func_data_cache_clear('sql', 'DISTINCT_code_FROM_languages.column');
 		}
 
 		if ($topic == 'Languages') {
@@ -204,6 +206,7 @@
 			func_data_cache_get("languages", array($language), true);
 		}
 
+		func_data_cache_clear('sql', 'DISTINCT_code_FROM_languages.column');
 		$top_message = array(
 			"content" => func_get_langvar_by_name("lbl_lng_variables_deleted")
 		);
@@ -228,6 +231,7 @@
 			func_fc_remove_cache(10, false, false, array($language));
 		}
 
+		func_data_cache_clear('sql', 'DISTINCT_code_FROM_languages.column');
 		$top_message = array(
 			"content" => func_get_langvar_by_name("lbl_languages_has_been_deleted")
 		);
@@ -346,6 +350,7 @@
 
 	func_data_cache_get("charsets", array(), true);
 	func_data_cache_clear("languages");
+	func_data_cache_clear('sql', 'DISTINCT_code_FROM_languages.column');
 
 	func_header_location("languages.php?language=$new_language&topic=$topic&page=$page");
 
