]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14617 removed PHP5 checks from global search
authorskodak <skodak>
Thu, 1 May 2008 21:22:01 +0000 (21:22 +0000)
committerskodak <skodak>
Thu, 1 May 2008 21:22:01 +0000 (21:22 +0000)
blocks/search/block_search.php
search/add.php
search/cron.php
search/delete.php
search/indexer.php
search/indexersplash.php
search/lib.php
search/query.php
search/stats.php
search/tests/index.php
search/update.php

index 92b05be2714a5e2256352b47da38c2d450aa7f7d..e021f9924353c9373e7fe84d0f30c9add1fcda46 100644 (file)
       $this->content = new stdClass;
       
       //lazy check for the moment
-      if (check_php_version("5.0.0")) {        
-        //fetch values if defined in admin, otherwise use defaults
-        $label  = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
-        $button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
-        
-        //basic search form
-        $this->content->text =
+      //fetch values if defined in admin, otherwise use defaults
+      $label  = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
+      $button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
+
+      //basic search form
+      $this->content->text =
             '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
           . '<label for="block_search_q">'. $label .'</label>'
           . '<input id="block_search_q" type="text" name="query_string" />'
           . '<input type="submit" value="'.$button.'" />'
           . '</div></form>';
-      } else {
-        $this->content->text = "Sorry folks, PHP 5 is needed for the new search module.";
-      } //else
-        
+
       //no footer, thanks
       $this->content->footer = '';
       
index cfdb5fb255c817387d6e7b7c068043158fa50d31..6421014ac8de861ddb5c127103525b61d3661acd 100644 (file)
@@ -33,14 +33,6 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } 
     
-/// check for php5 (lib.php)
-
-    if (!search_check_php5()) {
-        $phpversion = phpversion();
-        mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
-        exit(0);
-    } 
-    
     require_once("$CFG->dirroot/search/indexlib.php");
     
     $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
index 017c2fd45ae94ac401428f3883903a22f398ef24..dd04ae260a52b2d4fa1f8434dcb7d6f2315fa4d1 100644 (file)
 
     require_once("$CFG->dirroot/search/lib.php");
 
-    if (!search_check_php5()) {
-        $phpversion = phpversion();
-        mtrace("Sorry, cannot cron global search as it requires PHP 5.0.0 or later (currently using version $phpversion)");
-    } 
-    else if (empty($CFG->enableglobalsearch)) {
+    if (empty($CFG->enableglobalsearch)) {
         mtrace('Global searching is not enabled. Nothing performed by search.');
     }
     else{
index 21ed6f61efd7fc910b9c8a881655ca07be3cdd2e..1f6784444f404b12d995a25bab69715b99bc01fc 100644 (file)
@@ -32,13 +32,6 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } //if
     
-    //check for php5 (lib.php)
-    if (!search_check_php5()) {
-        $phpversion = phpversion();
-        mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
-        exit(0);
-    }
-    
     require_once("$CFG->dirroot/search/indexlib.php");
     
     $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
index a7396aefd3cb0fe3cb1ee173225ad80e320c7192..a48d505ab4eeda4b4674e66cb23f0642c153580b 100644 (file)
@@ -59,13 +59,6 @@ require_once("$CFG->dirroot/search/lib.php");
         exit(0);
     }
     
-/// check for php5 (lib.php)
-
-    if (!search_check_php5()) {
-        mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
-        exit(0);
-    } 
-    
     //php5 found, continue including php5-only files
     //require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
     require_once("$CFG->dirroot/search/indexlib.php");
index 8efdab6140bde9acab0d11047437b6dd3bd18a54..bd8b9208f323aea1193cc8fd083fa704210a79ab 100644 (file)
@@ -32,13 +32,6 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } 
     
-/// check for php5 (lib.php)
-
-    if (!search_check_php5()) {
-        mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
-        exit(0);
-    }
-    
     require_once("$CFG->dirroot/search/indexlib.php");
     $indexinfo = new IndexInfo();
     
index af40f8f1d9ff4faaf809865e11904983e0a45057..c38290f5781c6349024f4caa4b6249d6927c19ee 100644 (file)
@@ -22,7 +22,6 @@ function search_get_document_types($prefix = 'SEARCH_TYPE_') {
 function search_get_additional_modules() {
 function search_shorten_url($url, $length=30) {
 function search_escape_string($str) {
-function search_check_php5($feedback = false) {
 function search_stopwatch($cli = false) {
 function search_pexit($str = "") {
 */
@@ -113,23 +112,6 @@ function search_escape_string($str) {
     return $s;
 } //search_escape_string
 
-/**
-* get a real php 5 version number, using 5.0.0 arbitrarily
-* @param feedback if true, prints a feedback message to output.
-* @return true if version of PHP is high enough
-*/
-function search_check_php5($feedback = false) {
-    if (!check_php_version("5.0.0")) {
-        if ($feedback) {
-            print_heading(get_string('versiontoolow', 'search'));
-        }
-        return false;
-    } 
-    else {
-      return true;
-    } 
-} //search_check_php5
-
 /**
 * simple timer function, on first call, records a current microtime stamp, outputs result on 2nd call
 * @param cli an output formatting switch
index cd62c2cbefb040a080ccbbbee9ef734474bdb011..38ae1b76f14c3f75d11104a85029a4b1e6d2e28b 100644 (file)
     
 /// check for php5, but don't die yet (see line 52)
 
-    if ($check = search_check_php5()) {
-        require_once("{$CFG->dirroot}/search/querylib.php");
-    
-        $page_number  = optional_param('page', -1, PARAM_INT);
-        $pages        = ($page_number == -1) ? false : true;
-        $advanced     = (optional_param('a', '0', PARAM_INT) == '1') ? true : false;
-        $query_string = optional_param('query_string', '', PARAM_CLEAN);
-    
-        if ($pages && isset($_SESSION['search_advanced_query'])) {
-            // if both are set, then we are busy browsing through the result pages of an advanced query
-            $adv = unserialize($_SESSION['search_advanced_query']);
-        } else if ($advanced) {
-            // otherwise we are dealing with a new advanced query
-            unset($_SESSION['search_advanced_query']);
-            session_unregister('search_advanced_query');
-            
-            // chars to strip from strings (whitespace)
-            $chars = " \t\n\r\0\x0B,-+";
-            
-            // retrieve advanced query variables
-            $adv->mustappear  = trim(optional_param('mustappear', '', PARAM_CLEAN), $chars);
-            $adv->notappear   = trim(optional_param('notappear', '', PARAM_CLEAN), $chars);
-            $adv->canappear   = trim(optional_param('canappear', '', PARAM_CLEAN), $chars);
-            $adv->module      = optional_param('module', '', PARAM_CLEAN);
-            $adv->title       = trim(optional_param('title', '', PARAM_CLEAN), $chars);
-            $adv->author      = trim(optional_param('author', '', PARAM_CLEAN), $chars);
+    require_once("{$CFG->dirroot}/search/querylib.php");
+
+    $page_number  = optional_param('page', -1, PARAM_INT);
+    $pages        = ($page_number == -1) ? false : true;
+    $advanced     = (optional_param('a', '0', PARAM_INT) == '1') ? true : false;
+    $query_string = optional_param('query_string', '', PARAM_CLEAN);
+
+    if ($pages && isset($_SESSION['search_advanced_query'])) {
+        // if both are set, then we are busy browsing through the result pages of an advanced query
+        $adv = unserialize($_SESSION['search_advanced_query']);
+    } else if ($advanced) {
+        // otherwise we are dealing with a new advanced query
+        unset($_SESSION['search_advanced_query']);
+        session_unregister('search_advanced_query');
+        
+        // chars to strip from strings (whitespace)
+        $chars = " \t\n\r\0\x0B,-+";
+        
+        // retrieve advanced query variables
+        $adv->mustappear  = trim(optional_param('mustappear', '', PARAM_CLEAN), $chars);
+        $adv->notappear   = trim(optional_param('notappear', '', PARAM_CLEAN), $chars);
+        $adv->canappear   = trim(optional_param('canappear', '', PARAM_CLEAN), $chars);
+        $adv->module      = optional_param('module', '', PARAM_CLEAN);
+        $adv->title       = trim(optional_param('title', '', PARAM_CLEAN), $chars);
+        $adv->author      = trim(optional_param('author', '', PARAM_CLEAN), $chars);
+    } 
+
+    if ($advanced) {
+        //parse the advanced variables into a query string
+        //TODO: move out to external query class (QueryParse?)
+        
+        $query_string = '';
+        
+        // get all available module types
+        $module_types = array_merge(array('all'), array_values(search_get_document_types()));
+        $adv->module = in_array($adv->module, $module_types) ? $adv->module : 'all';
+        
+        // convert '1 2' into '+1 +2' for required words field
+        if (strlen(trim($adv->mustappear)) > 0) {
+            $query_string  = ' +'.implode(' +', preg_split("/[\s,;]+/", $adv->mustappear));
         } 
-    
-        if ($advanced) {
-            //parse the advanced variables into a query string
-            //TODO: move out to external query class (QueryParse?)
-            
-            $query_string = '';
-            
-            // get all available module types
-            $module_types = array_merge(array('all'), array_values(search_get_document_types()));
-            $adv->module = in_array($adv->module, $module_types) ? $adv->module : 'all';
-            
-            // convert '1 2' into '+1 +2' for required words field
-            if (strlen(trim($adv->mustappear)) > 0) {
-                $query_string  = ' +'.implode(' +', preg_split("/[\s,;]+/", $adv->mustappear));
-            } 
-            
-            // convert '1 2' into '-1 -2' for not wanted words field
-            if (strlen(trim($adv->notappear)) > 0) {
-                $query_string .= ' -'.implode(' -', preg_split("/[\s,;]+/", $adv->notappear));
-            } 
-            
-            // this field is left untouched, apart from whitespace being stripped
-            if (strlen(trim($adv->canappear)) > 0) {
-                $query_string .= ' '.implode(' ', preg_split("/[\s,;]+/", $adv->canappear));
-            } 
-            
-            // add module restriction
-            $doctypestr = get_string('doctype', 'search');
-            $titlestr = get_string('title', 'search');
-            $authorstr = get_string('author', 'search');
-            if ($adv->module != 'all') {
-                $query_string .= " +{$doctypestr}:".$adv->module;
-            } 
-            
-            // create title search string
-            if (strlen(trim($adv->title)) > 0) {
-                $query_string .= " +{$titlestr}:".implode(" +{$titlestr}:", preg_split("/[\s,;]+/", $adv->title));
-            } 
-            
-            // create author search string
-            if (strlen(trim($adv->author)) > 0) {
-                $query_string .= " +{$authorstr}:".implode(" +{$authorstr}:", preg_split("/[\s,;]+/", $adv->author));
-            } 
-            
-            // save our options if the query is valid
-            if (!empty($query_string)) {
-                $_SESSION['search_advanced_query'] = serialize($adv);
-            } 
+        
+        // convert '1 2' into '-1 -2' for not wanted words field
+        if (strlen(trim($adv->notappear)) > 0) {
+            $query_string .= ' -'.implode(' -', preg_split("/[\s,;]+/", $adv->notappear));
         } 
-    
-        // normalise page number
-        if ($page_number < 1) {
-            $page_number = 1;
+        
+        // this field is left untouched, apart from whitespace being stripped
+        if (strlen(trim($adv->canappear)) > 0) {
+            $query_string .= ' '.implode(' ', preg_split("/[\s,;]+/", $adv->canappear));
+        } 
+        
+        // add module restriction
+        $doctypestr = get_string('doctype', 'search');
+        $titlestr = get_string('title', 'search');
+        $authorstr = get_string('author', 'search');
+        if ($adv->module != 'all') {
+            $query_string .= " +{$doctypestr}:".$adv->module;
+        } 
+        
+        // create title search string
+        if (strlen(trim($adv->title)) > 0) {
+            $query_string .= " +{$titlestr}:".implode(" +{$titlestr}:", preg_split("/[\s,;]+/", $adv->title));
+        } 
+        
+        // create author search string
+        if (strlen(trim($adv->author)) > 0) {
+            $query_string .= " +{$authorstr}:".implode(" +{$authorstr}:", preg_split("/[\s,;]+/", $adv->author));
+        } 
+        
+        // save our options if the query is valid
+        if (!empty($query_string)) {
+            $_SESSION['search_advanced_query'] = serialize($adv);
         } 
-    
-        //run the query against the index
-        $sq = new SearchQuery($query_string, $page_number, 10, false);
     } 
-    
+
+    // normalise page number
+    if ($page_number < 1) {
+        $page_number = 1;
+    } 
+
+    //run the query against the index
+    $sq = new SearchQuery($query_string, $page_number, 10, false);
+
     if (!$site = get_site()) {
         redirect("index.php");
     } 
         print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, "&nbsp;", navmenu($site));
     }
     
-    //keep things pretty, even if php5 isn't available
-    if (!$check) {
-        print_heading(search_check_php5(true));
-        print_footer();
-        exit(0);
-    } 
-    
     print_box_start();
     print_heading($strquery);
     
index 8412241ef2787618006159ce98fffd27efb47a95..58edf1160799fffd0fec3f0d0304220a56ff4f33 100644 (file)
@@ -30,13 +30,9 @@ require_once("{$CFG->dirroot}/search/lib.php");
         error(get_string('globalsearchdisabled', 'search'));
     }
     
-/// check for php5, but don't die yet
-
-    if ($check = search_check_php5()) {
-        require_once("{$CFG->dirroot}/search/indexlib.php");
-        
-        $indexinfo = new IndexInfo();
-    } 
+    require_once("{$CFG->dirroot}/search/indexlib.php");
+    
+    $indexinfo = new IndexInfo();
     
     if (!$site = get_site()) {
         redirect("index.php");
@@ -58,12 +54,6 @@ require_once("{$CFG->dirroot}/search/lib.php");
     
 /// keep things pretty, even if php5 isn't available
 
-    if (!$check) {
-        print_heading(search_check_php5(true));
-        print_footer();
-        exit(0);
-    }
-    
     print_box_start();
     print_heading($strquery);
     
index 8b111808f534bdf1759463042f2cae13e7918a3a..19b36915e5bac649a9654600cb337f10d6aa5193 100644 (file)
@@ -38,13 +38,6 @@ mtrace("Testing global search capabilities:\n");
 
 $phpversion = phpversion();
 
-if (!search_check_php5()) {
-    mtrace("ERROR: PHP 5.0.0 or later required (currently using version ".phpversion().").");
-    exit(0);
-} else {
-    mtrace("Success: PHP 5.0.0 or later is installed (".phpversion().").\n");
-} //else
-
 //fix paths for testing
 set_include_path(get_include_path().":../");
 require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
index c83e2f859510e1f17a04669ced745a1999c3b5a5..08487f2c90a4771f3405c211f0da3c064692ad3e 100644 (file)
@@ -33,14 +33,6 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } 
     
-/// check for php5 (lib.php)
-
-    if (!search_check_php5()) {
-        $phpversion = phpversion();
-        mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")");
-        exit(0);
-    } 
-    
     require_once("$CFG->dirroot/search/indexlib.php");
     
     $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);