/** * @test */ public function removeAllByNamespaceReallyRemovesAllEntriesOfTheSpecifiedNamespaceFromTheDatabase() { $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_DELETEquery')->with('sys_registry', 'entry_namespace = \'tx_phpunit\''); $this->registry->removeAllByNamespace('tx_phpunit'); }
/** * */ public function startIndexingAction() { // make indexer instance and init /* @var $indexer tx_kesearch_indexer */ $indexer = GeneralUtility::makeInstance('tx_kesearch_indexer'); // get indexer configurations $indexerConfigurations = $indexer->getConfigurations(); $content = ''; // action: start indexer or remove lock if ($this->do == 'startindexer') { // start indexing in verbose mode with cleanup process $content .= $indexer->startIndexing(true, $this->extConf); } else { if ($this->do == 'rmLock') { // remove lock from registry - admin only! if ($this->getBackendUser()->user['admin']) { $this->registry->removeAllByNamespace('tx_kesearch'); } else { $content .= '<p>' . LocalizationUtility::translate('LLL:EXT:ke_search/Resources/Private/Language/locallang_mod.xml:not_allowed_remove_indexer_lock', 'KeSearch') . '</p>'; } } } // check for index process lock in registry // remove lock if older than 12 hours $lockTime = $this->registry->get('tx_kesearch', 'startTimeOfIndexer'); $compareTime = time() - 60 * 60 * 12; if ($lockTime !== null && $lockTime < $compareTime) { // lock is older than 12 hours // remove lock and show "start index" button $this->registry->removeAllByNamespace('tx_kesearch'); $lockTime = null; } // show information about indexer configurations and number of records // if action "start indexing" is not selected if ($this->do != 'startindexer') { $content .= $this->printNumberOfRecords(); $content .= $this->printIndexerConfigurations($indexerConfigurations); } // show "start indexing" or "remove lock" button if ($lockTime !== null) { if (!$this->getBackendUser()->user['admin']) { // print warning message for non-admins $content .= '<br /><p style="color: red; font-weight: bold;">WARNING!</p>'; $content .= '<p>The indexer is already running and can not be started twice.</p>'; } else { // show 'remove lock' button for admins $content .= '<br /><p>The indexer is already running and can not be started twice.</p>'; $content .= '<p>The indexing process was started at ' . strftime('%c', $lockTime) . '.</p>'; $content .= '<p>You can remove the lock by clicking the following button.</p>'; $moduleUrl = BackendUtility::getModuleUrl('web_KeSearchBackendModule', array('id' => $this->id, 'do' => 'rmLock')); $content .= '<br /><a class="lock-button" href="' . $moduleUrl . '">RemoveLock</a>'; } } else { // no lock set - show "start indexer" link if indexer configurations have been found if ($indexerConfigurations) { $moduleUrl = BackendUtility::getModuleUrl('web_KeSearchBackendModule', array('id' => $this->id, 'do' => 'startindexer')); $content .= '<br /><a class="index-button" href="' . $moduleUrl . '">' . LocalizationUtility::translate('LLL:EXT:ke_search/Resources/Private/Language/locallang_mod.xml:start_indexer', 'KeSearch') . '</a>'; } else { $content .= '<div class="alert alert-info">' . LocalizationUtility::translate('LLL:EXT:ke_search/Resources/Private/Language/locallang_mod.xml:no_indexer_configurations', 'KeSearch') . '</div>'; } } $this->view->assign('content', $content); }