Tweak so can still serve search results in php 5.2, a=chris

Chris Pollett [2012-05-03 18:May:rd]
Tweak so can still serve search results in php 5.2, a=chris
Filename
controllers/search_controller.php
lib/phrase_parser.php
diff --git a/controllers/search_controller.php b/controllers/search_controller.php
index e2fa7acd7..2a5d4bb9d 100755
--- a/controllers/search_controller.php
+++ b/controllers/search_controller.php
@@ -252,10 +252,16 @@ class SearchController extends Controller implements CrawlConstants
                 $data['INDEX_INFO'] = tl('search_controller_mix_info',
                     $index_info['DESCRIPTION']);
             } else {
-                $data['INDEX_INFO'] = tl('search_controller_crawl_info',
-                    $index_info['DESCRIPTION'],
-                    $index_info['VISITED_URLS_COUNT'],
-                    $index_info['COUNT']);
+                if(isset($index_info['DESCRIPTION']) &&
+                    isset($index_info['VISITED_URLS_COUNT']) &&
+                    isset($index_info['COUNT']) ) {
+                    $data['INDEX_INFO'] = tl('search_controller_crawl_info',
+                        $index_info['DESCRIPTION'],
+                        $index_info['VISITED_URLS_COUNT'],
+                        $index_info['COUNT']);
+                } else {
+                    $data['INDEX_INFO'] = "";
+                }
             }
         } else {
             $data['INDEX_INFO'] = "";
diff --git a/lib/phrase_parser.php b/lib/phrase_parser.php
index 5ae2a6fdb..9db9134b8 100755
--- a/lib/phrase_parser.php
+++ b/lib/phrase_parser.php
@@ -181,40 +181,42 @@ class PhraseParser
     {

         $acronym_pattern = "/[A-Za-z]\.(\s*[A-Za-z]\.)+/";
+        $replace_function = create_function('$matches', '
+            $result = "_".mb_strtolower(
+                mb_ereg_replace("\.", "", $matches[0]));
+            return $result;');
         $string = preg_replace_callback($acronym_pattern,
-            function($matches) {
-                $result = "_".mb_strtolower(
-                    mb_ereg_replace("\.", "", $matches[0]));
-                return $result;
-            }, $string);
+            $replace_function, $string);

         $ampersand_pattern = "/[A-Za-z]+(\s*(\s(\'n|\'N)\s|\&)\s*[A-Za-z])+/";
-        $string = preg_replace_callback($ampersand_pattern,
-            function($matches) {
-                $result = mb_strtolower(
-                    mb_ereg_replace("\s*(\'n|\'N|\&)\s*", "_and_",$matches[0]));
-                return $result;
-            }, $string);
+        $replace_function = create_function('$matches', '
+            $result = mb_strtolower(
+                mb_ereg_replace("\s*(\'n|\'N|\&)\s*", "_and_",$matches[0]));
+            return $result;
+        ');
+        $string = preg_replace_callback($ampersand_pattern, $replace_function,
+            $string);

         $url_or_email_pattern =
             '@((http|https)://([^ \t\r\n\v\f\'\"\;\,<>])*)|'.
             '([A-Z0-9._%-]+\@[A-Z0-9.-]+\.[A-Z]{2,4})@i';
+        $replace_function = create_function('$matches', '
+            $result =  mb_ereg_replace("\.", "_d_",$matches[0]);
+            $result =  mb_ereg_replace("\:", "_c_",$result);
+            $result =  mb_ereg_replace("\/", "_s_",$result);
+            $result =  mb_ereg_replace("\@", "_a_",$result);
+            $result =  mb_ereg_replace("\[", "_bo_",$result);
+            $result =  mb_ereg_replace("\]", "_bc_",$result);
+            $result =  mb_ereg_replace("\(", "_po_",$result);
+            $result =  mb_ereg_replace("\)", "_pc_",$result);
+            $result =  mb_ereg_replace("\?", "_q_",$result);
+            $result =  mb_ereg_replace("\=", "_e_",$result);
+            $result =  mb_ereg_replace("\&", "_a_",$result);
+            $result = mb_strtolower($result);
+            return $result;
+        ');
         $string = preg_replace_callback($url_or_email_pattern,
-            function($matches) {
-                $result =  mb_ereg_replace("\.", "_d_",$matches[0]);
-                $result =  mb_ereg_replace("\:", "_c_",$result);
-                $result =  mb_ereg_replace("\/", "_s_",$result);
-                $result =  mb_ereg_replace("\@", "_a_",$result);
-                $result =  mb_ereg_replace("\[", "_bo_",$result);
-                $result =  mb_ereg_replace("\]", "_bc_",$result);
-                $result =  mb_ereg_replace("\(", "_po_",$result);
-                $result =  mb_ereg_replace("\)", "_pc_",$result);
-                $result =  mb_ereg_replace("\?", "_q_",$result);
-                $result =  mb_ereg_replace("\=", "_e_",$result);
-                $result =  mb_ereg_replace("\&", "_a_",$result);
-                $result = mb_strtolower($result);
-                return $result;
-            }, $string);
+            $replace_function, $string);
     }

     /**
ViewGit