rebuildIndexes(); } public function rebuildIndexes($quiet = false) { include_once 'Zend/Search/Lucene.php'; ini_set("memory_limit", -1); ini_set('max_execution_time', 0); Filesystem::makeFolder(DocumentationSearch::get_index_location()); // only rebuild the index if we have to. Check for either flush or the time write.lock.file // was last altered $lock = DocumentationSearch::get_index_location() .'/write.lock.file'; $lockFileFresh = (file_exists($lock) && filemtime($lock) > (time() - (60 * 60 * 24))); echo "Building index in ". DocumentationSearch::get_index_location() . PHP_EOL; if ($lockFileFresh && !isset($_REQUEST['flush'])) { if (!$quiet) { echo "Index recently rebuilt. If you want to force reindex use ?flush=1"; } return true; } try { $index = Zend_Search_Lucene::open(DocumentationSearch::get_index_location()); $index->removeReference(); } catch (Zend_Search_Lucene_Exception $e) { user_error($e); } try { $index = Zend_Search_Lucene::create(DocumentationSearch::get_index_location()); } catch (Zend_Search_Lucene_Exception $c) { user_error($c); } // includes registration $manifest = new DocumentationManifest(true); $pages = $manifest->getPages(); if ($pages) { $count = 0; // iconv complains about all the markdown formatting // turn off notices while we parse if (!Director::is_cli()) { echo "