function _update() { global $conf; // upgrade to version 2 if (!@file_exists($conf['indexdir'] . '/pageword.idx')) { _lock(); idx_upgradePageWords(); _unlock(); } $data = array(); _quietecho("Searching pages... "); search($data, $conf['datadir'], 'search_allpages', array()); _quietecho(count($data) . " pages found.\n"); foreach ($data as $val) { _index($val['id']); } }
/** * Runs the indexer for the current page * * @author Andreas Gohr <*****@*****.**> */ function runIndexer() { global $ID; global $conf; print "runIndexer(): started" . NL; // Move index files (if needed) // Uses the importoldindex plugin to upgrade the index automatically. // FIXME: Remove this from runIndexer when it is no longer needed. if (@file_exists($conf['cachedir'] . '/page.idx') && (!@file_exists($conf['indexdir'] . '/page.idx') || !filesize($conf['indexdir'] . '/page.idx')) && !@file_exists($conf['indexdir'] . '/index_importing')) { echo "trigger TEMPORARY_INDEX_UPGRADE_EVENT\n"; $tmp = array(); // no event data trigger_event('TEMPORARY_INDEX_UPGRADE_EVENT', $tmp); } if (!$ID) { return false; } // check if indexing needed $idxtag = metaFN($ID, '.indexed'); if (@file_exists($idxtag)) { if (io_readFile($idxtag) >= INDEXER_VERSION) { $last = @filemtime($idxtag); if ($last > @filemtime(wikiFN($ID))) { print "runIndexer(): index for {$ID} up to date" . NL; return false; } } } // try to aquire a lock $lock = $conf['lockdir'] . '/_indexer.lock'; while (!@mkdir($lock, $conf['dmode'])) { usleep(50); if (time() - @filemtime($lock) > 60 * 5) { // looks like a stale lock - remove it @rmdir($lock); print "runIndexer(): stale lock removed" . NL; } else { print "runIndexer(): indexer locked" . NL; return false; } } if ($conf['dperm']) { chmod($lock, $conf['dperm']); } require_once DOKU_INC . 'inc/indexer.php'; // upgrade to version 2 if (!@file_exists($conf['indexdir'] . '/pageword.idx')) { idx_upgradePageWords(); } // do the work idx_addPage($ID); // we're finished - save and free lock io_saveFile(metaFN($ID, '.indexed'), INDEXER_VERSION); @rmdir($lock); print "runIndexer(): finished" . NL; return true; }
/** * Runs the indexer for the current page * * @author Andreas Gohr <*****@*****.**> */ function runIndexer() { global $ID; global $conf; print "runIndexer(): started" . NL; if (!$ID) { return false; } // check if indexing needed $idxtag = metaFN($ID, '.indexed'); if (@file_exists($idxtag)) { if (io_readFile($idxtag) >= INDEXER_VERSION) { $last = @filemtime($idxtag); if ($last > @filemtime(wikiFN($ID))) { print "runIndexer(): index for {$ID} up to date" . NL; return false; } } } // try to aquire a lock $lock = $conf['lockdir'] . '/_indexer.lock'; while (!@mkdir($lock, $conf['dmode'])) { usleep(50); if (time() - @filemtime($lock) > 60 * 5) { // looks like a stale lock - remove it @rmdir($lock); print "runIndexer(): stale lock removed" . NL; } else { print "runIndexer(): indexer locked" . NL; return false; } } if ($conf['dperm']) { chmod($lock, $conf['dperm']); } // upgrade to version 2 if (!@file_exists($conf['indexdir'] . '/pageword.idx')) { idx_upgradePageWords(); } // do the work idx_addPage($ID); // we're finished - save and free lock io_saveFile(metaFN($ID, '.indexed'), INDEXER_VERSION); @rmdir($lock); print "runIndexer(): finished" . NL; return true; }