/** * Check if there are still resources left for the process with the given id * Used to determine timeouts and to ensure a proper cleanup if there's a timeout * * @param string identification string for the process * @return boolean determines if the process is still active / has resources */ function CLI_checkIfProcessIsActive($pid) { $ret = false; $this->db->sql_query('BEGIN'); $res = $this->db->exec_SELECTquery('process_id,active,ttl', 'tx_crawler_process', 'process_id = \'' . $pid . '\' AND deleted=0', '', 'ttl', '0,1'); if ($row = $this->db->sql_fetch_assoc($res)) { $ret = intVal($row['active']) == 1; } $this->db->sql_query('COMMIT'); return $ret; }
/** * Clear the TYPO3 page cache for the given record. * If the record lies on a page, then we clear the cache of this page. * If the record has no PID column, we clear the cache of the current page as best-effort. * * Much of this functionality is taken from t3lib_tcemain::clear_cache() which unfortunately only works with logged-in BE user. * * @param $tableName Table name of the record * @param $uid UID of the record * @return void */ protected function clearPageCache($tableName, $uid) { $extbaseSettings = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration(); if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') { } else { // if disabled, return return; } $pageIdsToClear = array(); $storagePage = NULL; $columns = $this->databaseHandle->admin_get_fields($tableName); if (array_key_exists('pid', $columns)) { $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . intval($uid)); if ($row = $this->databaseHandle->sql_fetch_assoc($result)) { $storagePage = $row['pid']; $pageIdsToClear[] = $storagePage; } } elseif (isset($GLOBALS['TSFE'])) { // No PID column - we can do a best-effort to clear the cache of the current page if in FE $storagePage = $GLOBALS['TSFE']->id; $pageIdsToClear[] = $storagePage; } if ($storagePage === NULL) { return; } if (!isset($this->pageTSConfigCache[$storagePage])) { $this->pageTSConfigCache[$storagePage] = t3lib_BEfunc::getPagesTSconfig($storagePage); } if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) { $clearCacheCommands = t3lib_div::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), 1); $clearCacheCommands = array_unique($clearCacheCommands); foreach ($clearCacheCommands as $clearCacheCommand) { if (t3lib_div::testInt($clearCacheCommand)) { $pageIdsToClear[] = $clearCacheCommand; } } } // TODO check if we can hand this over to the Dispatcher to clear the page only once, this will save around 10% time while inserting and updating Tx_Extbase_Utility_Cache::clearPageCache($pageIdsToClear); }