public function execute($debug) { $startTime = microtime(true); foreach (Kwf_Util_Fulltext_Backend_Abstract::getInstance()->getSubroots() as $subroot) { $t = time(); if ($debug) { echo "\n[{$subroot}] check-for-invalid...\n"; } $cmd = Kwf_Config::getValue('server.phpCli') . " bootstrap.php fulltext check-for-invalid-subroot --subroot={$subroot}"; if ($debug) { $cmd .= " --debug"; } //if ($this->_getParam('silent')) $cmd .= " --silent"; passthru($cmd, $ret); if ($ret) { exit($ret); } if ($debug) { echo "[{$subroot}] check-for-invalid finished: " . Kwf_View_Helper_SecondsAsDuration::secondsAsDuration(time() - $t) . "\n\n"; } $t = time(); if ($debug) { echo "\n[{$subroot}] check-contents...\n"; } $cmd = Kwf_Config::getValue('server.phpCli') . " bootstrap.php fulltext check-contents-subroot --subroot={$subroot}"; if (isset($this->_options['skipDiff'])) { $cmd .= " --skip-diff"; } if ($debug) { $cmd .= " --debug"; } //if ($this->_getParam('silent')) $cmd .= " --silent"; passthru($cmd, $ret); if ($ret) { exit($ret); } if ($debug) { echo "[{$subroot}] check-contents finished: " . Kwf_View_Helper_SecondsAsDuration::secondsAsDuration(time() - $t) . "\n\n"; } $t = time(); if ($debug) { echo "\n[{$subroot}] optimize...\n"; } Kwf_Util_Fulltext_Backend_Abstract::getInstance()->optimize($debug); if ($debug) { echo "[{$subroot}] optimize finished: " . Kwf_View_Helper_SecondsAsDuration::secondsAsDuration(time() - $t) . "\n\n"; } } if ($debug) { echo "\ncomplete fulltext check-contents finished: " . Kwf_View_Helper_SecondsAsDuration::secondsAsDuration(microtime(true) - $startTime) . "s\n"; } }
public function rebuildAction() { Kwf_Util_MemoryLimit::set(512); $m = Kwf_Component_PagesMetaModel::getInstance(); $s = $m->select(); $m->updateRows(array('rebuilt' => 0), $s); $startTime = microtime(true); $numProcesses = 0; $queueFile = 'temp/pagemetaRebuildQueue'; $statsFile = 'temp/pagemetaRebuildStats'; $componentId = 'root'; if ($this->_getParam('componentId')) { $componentId = $this->_getParam('componentId'); } file_put_contents($queueFile, $componentId); $stats = array('pages' => 0, 'addedPages' => 0); file_put_contents($statsFile, serialize($stats)); while (true) { $numProcesses++; $cmd = Kwf_Config::getValue('server.phpCli') . " bootstrap.php component-pages-meta rebuild-worker"; if ($this->_getParam('debug')) { $cmd .= " --debug"; } if ($this->_getParam('verbose')) { $cmd .= " --verbose"; } passthru($cmd, $status); if ($status != 0) { throw new Kwf_Exception("child process failed"); } if ($this->_getParam('debug')) { echo "memory_usage (parent): " . memory_get_usage() / (1024 * 1024) . "MB\n"; } if (!file_get_contents($queueFile)) { if ($this->_getParam('debug')) { echo "fertig.\n"; } break; } } if ($this->_getParam('debug')) { $stats = unserialize(file_get_contents($statsFile)); echo "fulltext reindex finished.\n"; echo "duration: " . Kwf_View_Helper_SecondsAsDuration::secondsAsDuration(microtime(true) - $startTime) . "s\n"; echo "used child processes: {$numProcesses}\n"; echo "processed pages: {$stats['pages']}\n"; echo "indexed pages: {$stats['addedPages']}\n"; } //delete rows that have not been rebuilt $m = Kwf_Component_PagesMetaModel::getInstance(); $s = $m->select(); $s->whereEquals('rebuilt', false); $m->deleteRows($s); exit; }
public function rebuildAction() { Kwf_Util_MemoryLimit::set(512); if (!$this->_getParam('skip-check-for-invalid')) { $cmd = Kwf_Config::getValue('server.phpCli') . " bootstrap.php component-pages-meta check-for-invalid"; if ($this->_getParam('debug')) { $cmd .= " --debug"; } system($cmd); } $startTime = microtime(true); $numProcesses = 0; $queueFile = 'temp/pagemetaRebuildQueue'; $statsFile = 'temp/pagemetaRebuildStats'; $componentId = 'root'; if ($this->_getParam('componentId')) { $componentId = $this->_getParam('componentId'); } file_put_contents($queueFile, $componentId); $stats = array('pages' => 0, 'addedPages' => 0); file_put_contents($statsFile, serialize($stats)); while (true) { $numProcesses++; $cmd = Kwf_Config::getValue('server.phpCli') . " bootstrap.php component-pages-meta rebuild-worker"; if ($this->_getParam('debug')) { $cmd .= " --debug"; } system($cmd, $status); if ($status != 0) { throw new Kwf_Exception("child process failed"); } if ($this->_getParam('debug')) { echo "memory_usage (parent): " . memory_get_usage() / (1024 * 1024) . "MB\n"; } if (!file_get_contents($queueFile)) { if ($this->_getParam('debug')) { echo "fertig.\n"; } break; } } if (!$this->_getParam('silent')) { $stats = unserialize(file_get_contents($statsFile)); echo "fulltext reindex finished.\n"; echo "duration: " . Kwf_View_Helper_SecondsAsDuration::secondsAsDuration(microtime(true) - $startTime) . "s\n"; echo "used child processes: {$numProcesses}\n"; echo "processed pages: {$stats['pages']}\n"; echo "indexed pages: {$stats['addedPages']}\n"; } exit; }