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

Attempt to reduce query retrieval time by sending less data in raw=1 case, a=chris

Chris Pollett [2019-07-11 18:Jul:th]
Attempt to reduce query retrieval time by sending less data in raw=1 case, a=chris
Filename
src/controllers/SearchController.php
src/library/index_bundle_iterators/NetworkIterator.php
src/models/PhraseModel.php
diff --git a/src/controllers/SearchController.php b/src/controllers/SearchController.php
index 8ad9f87d2..a36c63e7c 100755
--- a/src/controllers/SearchController.php
+++ b/src/controllers/SearchController.php
@@ -145,7 +145,8 @@ class SearchController extends Controller implements CrawlConstants
                 return;
             }
         }
-        $data['ELAPSED_TIME'] = L\changeInMicrotime($start_time);
+        $data['ELAPSED_TIME'] = number_format(
+            L\changeInMicrotime($start_time),6);
         if ($view == "serial" || $view == "json") {
             $data['BASE_URL'] = C\BASE_URL;
             if (isset($data["PAGES"])) {
@@ -160,8 +161,8 @@ class SearchController extends Controller implements CrawlConstants
                         round($data["PAGES"][$i][self::RELEVANCE], 3);
                 }
             }
-            $data['TOTAL_TIME'] = L\changeInMicrotime(
-                $_SERVER["REQUEST_TIME_FLOAT"]);
+            $data['TOTAL_TIME'] = number_format(L\changeInMicrotime(
+                $_SERVER["REQUEST_TIME_FLOAT"]), 6);
             if ($view == "serial") {
                 if (isset($_REQUEST['mirror']) &&
                     $_REQUEST['mirror'] == "true") {
@@ -935,9 +936,6 @@ class SearchController extends Controller implements CrawlConstants
         $data['RAW'] = $raw;
         $data['PAGES'] = (isset($phrase_results['PAGES'])) ?
              $phrase_results['PAGES']: [];
-        $data['THESAURUS_VARIANTS'] =
-            (isset($phrase_results['THESAURUS_VARIANTS'])) ?
-             $phrase_results['THESAURUS_VARIANTS']: [];
         $data['BEST_ANSWER'] = (isset($phrase_results['BEST_ANSWER'])) ?
             $phrase_results['BEST_ANSWER'] : null;
         $data['SAVE_POINT'] = (isset($phrase_results["SAVE_POINT"])) ?
diff --git a/src/library/index_bundle_iterators/NetworkIterator.php b/src/library/index_bundle_iterators/NetworkIterator.php
index 5959d9d1d..c41f57c18 100644
--- a/src/library/index_bundle_iterators/NetworkIterator.php
+++ b/src/library/index_bundle_iterators/NetworkIterator.php
@@ -117,7 +117,7 @@ class NetworkIterator extends IndexBundleIterator
         $this->hard_query = false;
         $this->base_query = "q=".urlencode($query).
             "&f=serial&network=false&raw=1&its=$timestamp&guess=false";
-        if ($save_timestamp_name!="") {
+        if ($save_timestamp_name != "") {
             // used for archive crawls of crawl mixes
             $this->base_query .= "&save_timestamp=$save_timestamp_name";
         }
diff --git a/src/models/PhraseModel.php b/src/models/PhraseModel.php
index c732227e8..6b6b9658f 100755
--- a/src/models/PhraseModel.php
+++ b/src/models/PhraseModel.php
@@ -249,7 +249,7 @@ class PhraseModel extends ParallelModel
                 if (isset($presentation_parts[$i][1])) {
                     $count += $presentation_parts[$i][1];
                 } else {
-                    $count ++;
+                    $count++;
                 }
             }
         }
@@ -1164,8 +1164,8 @@ class PhraseModel extends ParallelModel
         if ($save_timestamp_name != "" && ($queue_servers == [] ||
             $this->isSingleLocalhost($queue_servers))) {
             // used for archive crawls of crawl mixes
-            $save_file = C\CRAWL_DIR.'/schedules/'.self::save_point.
-                $save_timestamp_name.".txt";
+            $save_file = C\CRAWL_DIR . '/schedules/' . self::save_point.
+                $save_timestamp_name . ".txt";
             $iterators = $query_iterator->save_iterators;
             $cnt_iterators = count($iterators);
             $save_point = [];
@@ -1197,8 +1197,8 @@ class PhraseModel extends ParallelModel
                 for ($i = 0; $i < $result_count; $i++) {
                     for ($j = 0; $j < $max_user_ranks; $j++) {
                         if (isset($pages[$i][self::USER_RANKS][$j])) {
-                            $pages[$i]["USCORE$j"] =
-                                $pages[$i][self::USER_RANKS][$j];
+                            $pages[$i]["USCORE$j"] = number_format(
+                                $pages[$i][self::USER_RANKS][$j], 4);
                         } else {
                             $pages[$i]["USCORE$j"] = 0;
                         }
@@ -1255,7 +1255,20 @@ class PhraseModel extends ParallelModel
         if ($raw == 1 && $save_timestamp_name == "") {
             $pages = array_slice($pages, $start_slice);
             $pages = array_slice($pages, $limit - $start_slice, $num);
-            $results['PAGES'] = & $pages;
+            $result_pages = [];
+            foreach ($pages as $p) {
+                $result_page = [
+                    self::USER_RANKS => $p[self::USER_RANKS],
+                    self::DOC_RANK => number_format($p[self::DOC_RANK], 4),
+                    self::RELEVANCE => number_format($p[self::RELEVANCE], 4),
+                    self::PROXIMITY => number_format($p[self::PROXIMITY],4),
+                    self::MACHINE_ID => $p[self::MACHINE_ID],
+                    self::KEY => $p[self::KEY],
+                    self::CRAWL_TIME => $p[self::CRAWL_TIME],
+                    self::SUMMARY_OFFSET => $p[self::SUMMARY_OFFSET] ];
+                $result_pages[] = $result_page;
+            }
+            $results['PAGES'] = & $result_pages;
             if ($old_to_retrieve != $to_retrieve) {
                 $results['HARD_QUERY'] = $old_to_retrieve;
             }
ViewGit