$source = $paramList[1]; $destination = $paramList[0]; $invalid = isset($paramList[2]) ? $paramList[2] : null; if (!isset($fileContentCache[$source])) { $cli->output("Fetching URL: {$source}"); $fileContentCache[$source] = eZHTTPTool::getDataByURL($source, false, eZStaticCache::USER_AGENT); } if ($fileContentCache[$source] === false) { $cli->error("Could not grab content from \"{$source}\", is the hostname correct and Apache running?"); if ($invalid !== null) { $deleteParams[] = $param; continue; } $markInvalidParams[] = $param; } else { eZStaticCache::storeCachedFile($destination, $fileContentCache[$source]); $deleteParams[] = $param; } } if (!empty($markInvalidParams)) { $db->begin(); $db->query("UPDATE ezpending_actions SET param=( " . $db->concatString(array("param", "',invalid'")) . " ) WHERE param IN ( '" . implode("','", $markInvalidParams) . "' )"); $db->commit(); } if (!empty($deleteParams)) { $db->begin(); $db->query("DELETE FROM ezpending_actions WHERE action='static_store' AND param IN ( '" . implode("','", $deleteParams) . "' )"); $db->commit(); } else { $offset += $limit; }
/** * This function goes over the list of recorded actions and excecutes them. */ static function executeActions() { if ( empty( self::$actionList ) ) { return; } $fileContentCache = array(); $doneDestList = array(); $ini = eZINI::instance( 'staticcache.ini'); $clearByCronjob = ( $ini->variable( 'CacheSettings', 'CronjobCacheClear' ) == 'enabled' ); if ( $clearByCronjob ) { $db = eZDB::instance(); } foreach ( self::$actionList as $action ) { list( $action, $parameters ) = $action; switch( $action ) { case 'store': list( $destination, $source ) = $parameters; if ( isset( $doneDestList[$destination] ) ) continue 2; if ( $clearByCronjob ) { $param = $db->escapeString( $destination . ',' . $source ); $db->query( 'INSERT INTO ezpending_actions( action, param ) VALUES ( \'static_store\', \''. $param . '\' )' ); $doneDestList[$destination] = 1; } else { if ( !isset( $fileContentCache[$source] ) ) { if ( eZHTTPTool::getDataByURL( $source, true, eZStaticCache::USER_AGENT ) ) $fileContentCache[$source] = eZHTTPTool::getDataByURL( $source, false, eZStaticCache::USER_AGENT ); else $fileContentCache[$source] = false; } if ( $fileContentCache[$source] === false ) { eZDebug::writeError( "Could not grab content (from $source), is the hostname correct and Apache running?", 'Static Cache' ); } else { eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] ); $doneDestList[$destination] = 1; } } break; } } self::$actionList = array(); }