]> git.mjollnir.org Git - moodle.git/commitdiff
fixes MDL-14774 and MDL-14777
authordiml <diml>
Sat, 10 May 2008 14:11:10 +0000 (14:11 +0000)
committerdiml <diml>
Sat, 10 May 2008 14:11:10 +0000 (14:11 +0000)
Exception issues should find a solution here. Fixes inclusion path
problems relative to Zend baseroot.

search/add.php
search/delete.php
search/update.php

index 6421014ac8de861ddb5c127103525b61d3661acd..a7a5e7780df744601c50bfd4a0b831777abf4d54 100644 (file)
@@ -1,25 +1,30 @@
 <?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage search_engine
-* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* Asynchronous adder for new indexable contents
-*
-* Major chages in this review is passing the xxxx_db_names return to
-* multiple arity to handle multiple document types modules
-*/
-
-/**
-* includes and requires 
-*/
-require_once('../config.php');
-require_once("$CFG->dirroot/search/lib.php");
+    /**
+    * Global Search Engine for Moodle
+    *
+    * @package search
+    * @category core
+    * @subpackage search_engine
+    * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+    * @date 2008/03/31
+    * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+    *
+    * Asynchronous adder for new indexable contents
+    *
+    * Major chages in this review is passing the xxxx_db_names return to
+    * multiple arity to handle multiple document types modules
+    */
+    
+    /**
+    * includes and requires 
+    */
+    require_once('../config.php');
+    require_once("$CFG->dirroot/search/lib.php");
+    require_once("$CFG->dirroot/search/indexlib.php");
+    
+/// makes inclusions of the Zend Engine more reliable
+    $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;
+    ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));
 
 /// checks global search activation
     
@@ -33,9 +38,20 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } 
     
-    require_once("$CFG->dirroot/search/indexlib.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);
+    } 
     
-    $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+    try {
+        $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+    } catch(LuceneException $e) {
+        mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again.");
+        return;
+    }
     $dbcontrol = new IndexDBControl();
     $addition_count = 0;
     $startindextime = time();
@@ -46,7 +62,6 @@ require_once("$CFG->dirroot/search/lib.php");
     mtrace('Index size before: '.$CFG->search_index_size."\n");
     
 /// get all modules
-
     if ($mods = get_records_select('modules')) {
     
 /// append virtual modules onto array
@@ -148,4 +163,4 @@ require_once("$CFG->dirroot/search/lib.php");
     mtrace("Added $addition_count documents.");
     mtrace('Index size after: '.$index->count());
 
-?>
+?>
\ No newline at end of file
index 1f6784444f404b12d995a25bab69715b99bc01fc..dcd9ab599ad2bf9578702b36bf74646b5357cad4 100644 (file)
@@ -1,29 +1,32 @@
 <?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage search_engine
-* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* Asynchronous index cleaner
-*
-* Major chages in this review is passing the xxxx_db_names return to
-* multiple arity to handle multiple document types modules
-*/
-
-/**
-* includes and requires
-*/
-require_once('../config.php');
-require_once("$CFG->dirroot/search/lib.php");
-
-
-    require_login();
+    /**
+    * Global Search Engine for Moodle
+    *
+    * @package search
+    * @category core
+    * @subpackage search_engine
+    * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+    * @date 2008/03/31
+    * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+    *
+    * Asynchronous index cleaner
+    *
+    * Major chages in this review is passing the xxxx_db_names return to
+    * multiple arity to handle multiple document types modules
+    */
+    
+    /**
+    * includes and requires
+    */
+    require_once('../config.php');
+    require_once("$CFG->dirroot/search/lib.php");
+    require_once("$CFG->dirroot/search/indexlib.php");    
     
+/// makes inclusions of the Zend Engine more reliable                               
+    $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;                   
+    ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));require_login();
+    
+/// checks global search activation
     if (empty($CFG->enableglobalsearch)) {
         error(get_string('globalsearchdisabled', 'search'));
     }
@@ -32,9 +35,19 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } //if
     
-    require_once("$CFG->dirroot/search/indexlib.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);
+    }
     
-    $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+    try {
+        $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+    } catch(LuceneException $e) {
+        mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again.");
+        return;
+    }
     $dbcontrol = new IndexDBControl();
     $deletion_count = 0;
     $startcleantime = time();
@@ -42,6 +55,7 @@ require_once("$CFG->dirroot/search/lib.php");
     mtrace('Starting clean-up of removed records...');
     mtrace('Index size before: '.$CFG->search_index_size."\n");
     
+/// check all modules
     if ($mods = get_records_select('modules')) {
         $mods = array_merge($mods, search_get_additional_modules());
         
index 08487f2c90a4771f3405c211f0da3c064692ad3e..7af53d174fe8161d003001d78a28328f9790482f 100644 (file)
@@ -1,25 +1,30 @@
 <?php
-/**
-* Global Search Engine for Moodle
-*
-* @package search
-* @category core
-* @subpackage search_engine
-* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
-* @date 2008/03/31
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-*
-* Index asynchronous updator
-*
-* Major chages in this review is passing the xxxx_db_names return to
-* multiple arity to handle multiple document types modules
-*/
+    /**
+    * Global Search Engine for Moodle
+    *
+    * @package search
+    * @category core
+    * @subpackage search_engine
+    * @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+    * @date 2008/03/31
+    * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+    *
+    * Index asynchronous updator
+    *
+    * Major chages in this review is passing the xxxx_db_names return to
+    * multiple arity to handle multiple document types modules
+    */
+    
+    /**
+    * includes and requires
+    */
+    require_once('../config.php');
+    require_once("$CFG->dirroot/search/lib.php");
+    require_once("$CFG->dirroot/search/indexlib.php");
 
-/**
-* includes and requires
-*/
-require_once('../config.php');
-require_once("$CFG->dirroot/search/lib.php");
+/// makes inclusions of the Zend Engine more reliable                               
+    $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;                   
+    ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path'));require_login();
 
 /// checks global search activation
 
@@ -33,9 +38,19 @@ require_once("$CFG->dirroot/search/lib.php");
         error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php");
     } 
     
-    require_once("$CFG->dirroot/search/indexlib.php");
-    
-    $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+/// 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);
+    } 
+        
+    try {
+        $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
+    } catch(LuceneException $e) {
+        mtrace("Could not construct a valid index. Maybe the first indexation was never made, or files might be corrupted. Run complete indexation again.");
+        return;
+    }
     $dbcontrol = new IndexDBControl();
     $update_count = 0;
     $indexdate = $CFG->search_indexer_update_date;
@@ -126,7 +141,8 @@ require_once("$CFG->dirroot/search/lib.php");
                             mtrace("  Add: $add->title (database id = $add->dbid, moodle instance id = $add->docid)");
                             $index->addDocument($add);
                         } 
-                    } else {
+                    }
+                    else{
                         mtrace("No types to update.\n");
                     }
                     mtrace("Finished $mod->name.\n");