コード例 #1
0
ファイル: class.tx_crawler_lib.php プロジェクト: b13/crawler
    /**
     * Release a process and the required resources
     *
     * @param  mixed    $releaseIds   string with a single process-id or array with multiple process-ids
     * @param  boolean  $withinLock   show whether the DB-actions are included within an existing lock
     * @return boolean
     */
    function CLI_releaseProcesses($releaseIds, $withinLock = false)
    {
        if (!is_array($releaseIds)) {
            $releaseIds = array($releaseIds);
        }
        if (!count($releaseIds) > 0) {
            return false;
            //nothing to release
        }
        if (!$withinLock) {
            $this->db->sql_query('BEGIN');
        }
        // some kind of 2nd chance algo - this way you need at least 2 processes to have a real cleanup
        // this ensures that a single process can't mess up the entire process table
        // mark all processes as deleted which have no "waiting" queue-entires and which are not active
        $this->db->exec_UPDATEquery('tx_crawler_queue', 'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)', array('process_scheduled' => 0, 'process_id' => ''));
        $this->db->exec_UPDATEquery('tx_crawler_process', 'active=0 AND deleted=0
			AND NOT EXISTS (
				SELECT * FROM tx_crawler_queue
				WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id
				AND tx_crawler_queue.exec_time = 0
			)', array('deleted' => '1'));
        // mark all requested processes as non-active
        $this->db->exec_UPDATEquery('tx_crawler_process', 'process_id IN (\'' . implode('\',\'', $releaseIds) . '\') AND deleted=0', array('active' => '0'));
        $this->db->exec_UPDATEquery('tx_crawler_queue', 'exec_time=0 AND process_id IN ("' . implode('","', $releaseIds) . '")', array('process_scheduled' => 0, 'process_id' => ''));
        if (!$withinLock) {
            $this->db->sql_query('COMMIT');
        }
        return true;
    }
コード例 #2
0
 /**
  * Relative filemounts are transformed to relate to our fileadmin/ storage
  * and their path is modified to be a valid resource location
  */
 protected function migrateRelativeFilemounts()
 {
     $relativeFilemounts = $this->db->exec_SELECTgetRows('*', 'sys_filemounts', 'base = 1' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_filemounts'));
     foreach ($relativeFilemounts as $filemount) {
         $this->db->exec_UPDATEquery('sys_filemounts', 'uid=' . intval($filemount['uid']), array('base' => $this->storage->getUid(), 'path' => '/' . ltrim($filemount['path'], '/')));
         $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
     }
 }