viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Fix a Bug in TrendingHighlightsJob causing only default locale to generate, a=chris

Chris Pollett [2020-07-12 03:Jul:th]
Fix a Bug in TrendingHighlightsJob causing only default locale to generate, a=chris
Filename
src/configs/Config.php
src/library/media_jobs/TrendingHighlightsJob.php
src/locale/zh_CN/resources/Tokenizer.php
diff --git a/src/configs/Config.php b/src/configs/Config.php
index ac858820b..37f7af37b 100755
--- a/src/configs/Config.php
+++ b/src/configs/Config.php
@@ -169,7 +169,7 @@ nsdefine('MIN_AD_VERSION', 36);
  * Version number for upgrading locale resource folders and for upgrading
  * public and help wikis
  */
-nsdefine('RESOURCES_WIKI_VERSION', 7);
+nsdefine('RESOURCES_WIKI_VERSION', 8);
 /**
  * nsdefine's the BASE_URL constant for this script
  * if run from the command line as part of index.php HTTP server scrip
diff --git a/src/library/media_jobs/TrendingHighlightsJob.php b/src/library/media_jobs/TrendingHighlightsJob.php
index 47257a747..9d36db500 100644
--- a/src/library/media_jobs/TrendingHighlightsJob.php
+++ b/src/library/media_jobs/TrendingHighlightsJob.php
@@ -215,7 +215,9 @@ class TrendingHighlightsJob extends MediaJob
         return ($test_mode) ? $test_results : true;
     }
     /**
-     * @param array $subsearches
+     * Computes arrays of data used to display the news and trending highlights
+     * on the search landing page. Saves these precomputed arrays to
+     * C\WORK_DIRECTORY . "/cache/trends" under a file for each locale
      */
     public function computeLandingHighlights()
     {
@@ -233,6 +235,7 @@ class TrendingHighlightsJob extends MediaJob
         $trend_dir = C\WORK_DIRECTORY . "/cache/trends";
         foreach ($locale_list as $language) {
             $locale_tag = $language['LOCALE_TAG'];
+            $locale_tag_major = (explode("-", $locale_tag))[0];
             $highlights_file = "$trend_dir/highlights_$locale_tag.txt";
             $num_random_trends = 9;
             $highlights = [];
@@ -270,7 +273,7 @@ class TrendingHighlightsJob extends MediaJob
                         'CATEGORY' => $highlight['CATEGORY'],
                         "ORDER" => $subsearch['ORDER'],
                         'DATA' => $trending_model->randomTrends(
-                            $locale, $highlight['CATEGORY'],
+                            $locale_tag, $highlight['CATEGORY'],
                             $num_random_trends)
                     ];
                 } else {
@@ -286,8 +289,9 @@ class TrendingHighlightsJob extends MediaJob
                             $query;
                     }
                     $query = preg_replace('/lang:default-major/ui', "lang:" .
-                        $locale_major, $query);
-                    $query = preg_replace('/lang:default/u', "lang:" . $locale,
+                        $locale_tag_major, $query);
+                    $query = preg_replace('/lang:default/u',
+                        "lang:" . $locale_tag,
                         $query);
                     $query_results = $phrase_model->getPhrasePageResults(
                         $query, 0, 5, false, $verticals_model, true, 0,
diff --git a/src/locale/zh_CN/resources/Tokenizer.php b/src/locale/zh_CN/resources/Tokenizer.php
index 2270f7344..f0769c5a7 100755
--- a/src/locale/zh_CN/resources/Tokenizer.php
+++ b/src/locale/zh_CN/resources/Tokenizer.php
@@ -253,6 +253,8 @@ class Tokenizer
     }
     /**
      * Check if the term passed in is a Cardinal Number
+     * @param string $term to check if a cardinal number or not
+     * @return bool whether it is a cardinal or not
      */
     public static function isCardinalNumber($term)
     {
@@ -267,6 +269,8 @@ class Tokenizer
     }
     /*
      * Check if the term passed in is a Ordinal Number
+     * @param string $term to check if a ordinal number or not
+     * @return bool whether it is a ordinal or not
      */
     public static function isOrdinalNumber($term)
     {
@@ -276,6 +280,8 @@ class Tokenizer
     }
     /*
      * Check if the term passed in is a date
+     * @param string $term to check if a date or not
+     * @return bool whether it is a date or not
      */
     public static function isDate($term)
     {
@@ -293,7 +299,7 @@ class Tokenizer
     }
     /**
      * Check if all the chars in the term is NOT current language
-     * @param $term is a string that to be checked
+     * @param string $term is a string that to be checked
      * @return bool true if all the chars in $term is NOT current language
      *         false otherwise
      */
ViewGit