浏览代码

Fixing PHP notices.

Julio Montoya 11 年之前
父节点
当前提交
67fe0a6363
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 10 5
      main/inc/lib/internationalization.lib.php
  2. 2 2
      main/inc/lib/internationalization_internal.lib.php

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

@@ -3693,13 +3693,18 @@ function api_detect_encoding($string, $language = null) {
     $encodings = api_get_valid_encodings();
     foreach ($encodings as & $encoding) {
         if (api_is_encoding_supported($encoding) && !api_is_utf8($encoding)) {
-            $result_array = & _api_compare_n_grams(
-                _api_generate_n_grams(
-                    api_substr($string, 0, LANGUAGE_DETECT_MAX_LENGTH, $encoding),
-                    $encoding
-                ),
+            $stringToParse = api_substr($string, 0, LANGUAGE_DETECT_MAX_LENGTH, $encoding);
+
+            $strintToParse2 = _api_generate_n_grams(
+                $stringToParse,
                 $encoding
             );
+
+            $result_array = _api_compare_n_grams(
+                $strintToParse2,
+                $encoding
+            );
+
             if (!empty($result_array)) {
                 list($key, $delta_points) = each($result_array);
                 if ($delta_points < $delta_points_min) {

+ 2 - 2
main/inc/lib/internationalization_internal.lib.php

@@ -54,7 +54,7 @@ function _api_get_latin1_compatible_languages() {
  * @param int $n_max (optional)			The limit if the number of characters that a n-gram may contain.
  * @return array						An array that contains cunstructed n-grams, sorted in reverse order by their frequences. Frequences are not stored in the array.
  */
-function &_api_generate_n_grams(&$string, $encoding, $n_grams_max = 350, $n_max = 4) {
+function _api_generate_n_grams(&$string, $encoding, $n_grams_max = 350, $n_max = 4) {
     if (empty($string)) {
         return array();
     }
@@ -91,7 +91,7 @@ function &_api_generate_n_grams(&$string, $encoding, $n_grams_max = 350, $n_max
  * If you set the value of $max_delta too low, no language will be recognized.
  * $max_delta = 400 * 350 = 140000 is the best detection with lowest speed.
  */
-function & _api_compare_n_grams(&$n_grams, $encoding, $max_delta = LANGUAGE_DETECT_MAX_DELTA) {
+function _api_compare_n_grams(&$n_grams, $encoding, $max_delta = LANGUAGE_DETECT_MAX_DELTA) {
     static $language_profiles;
     if (!isset($language_profiles)) {
         // Reading the language profile files from the internationalization database.