|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Created on: <28-May-2007 17:44:41 ar> 00004 // 00005 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00006 // SOFTWARE NAME: eZ Publish 00007 // SOFTWARE RELEASE: 4.0.x 00008 // COPYRIGHT NOTICE: Copyright (C) 1999-2009 eZ Systems AS 00009 // SOFTWARE LICENSE: GNU General Public License v2.0 00010 // NOTICE: > 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of version 2.0 of the GNU General 00013 // Public License as published by the Free Software Foundation. 00014 // 00015 // This program is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of version 2.0 of the GNU General 00021 // Public License along with this program; if not, write to the Free 00022 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00023 // MA 02110-1301, USA. 00024 // 00025 // 00026 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00027 // 00028 00029 /*! \file staticcache_cleanup.php 00030 */ 00031 00032 //include_once( 'lib/ezdb/classes/ezdb.php' ); 00033 //include_once( 'kernel/classes/ezstaticcache.php' ); 00034 00035 if ( !$isQuiet ) 00036 { 00037 $cli->output( "Starting processing pending static cache cleanups" ); 00038 } 00039 00040 $db = eZDB::instance(); 00041 00042 $offset = 0; 00043 $limit = 20; 00044 $doneDestList = array(); 00045 $fileContentCache = array(); 00046 00047 while( true ) 00048 { 00049 $entries = $db->arrayQuery( "SELECT param FROM ezpending_actions WHERE action = 'static_store'", 00050 array( 'limit' => $limit, 00051 'offset' => $offset ) ); 00052 $inSQL = ''; 00053 00054 if ( is_array( $entries ) and count( $entries ) ) 00055 { 00056 $db->begin(); 00057 foreach ( $entries as $entry ) 00058 { 00059 $param = $entry['param']; 00060 $destination = explode( ',', $param ); 00061 $source = $destination[1]; 00062 $destination = $destination[0]; 00063 $success = false; 00064 00065 if ( !isset( $doneDestList[$destination] ) ) 00066 { 00067 if ( !isset( $fileContentCache[$source] ) ) 00068 { 00069 if ( !$isQuiet ) 00070 { 00071 $cli->output( "\tFetching URL: $source" ); 00072 } 00073 $fileContentCache[$source] = eZHTTPTool::getDataByURL( $source, false, eZStaticCache::USER_AGENT ); 00074 } 00075 if ( $fileContentCache[$source] === false ) 00076 { 00077 $cli->output( "\tCould not grab content, is the hostname correct and Apache running?" ); 00078 } 00079 else 00080 { 00081 eZStaticCache::storeCachedFile( $destination, $fileContentCache[$source] ); 00082 $doneDestList[$destination] = 1; 00083 $success = true; 00084 } 00085 } 00086 else 00087 { 00088 $success = true; 00089 } 00090 00091 if ( $success ) 00092 { 00093 if ( $inSQL != '' ) 00094 { 00095 $inSQL .= ', '; 00096 } 00097 $inSQL .= '\'' . $param . '\''; 00098 } 00099 } 00100 00101 $db->query( "DELETE FROM ezpending_actions WHERE action='static_store' AND param IN ($inSQL)" ); 00102 $db->commit(); 00103 } 00104 else 00105 { 00106 break; // No valid result from ezpending_actions 00107 } 00108 } 00109 00110 if ( !$isQuiet ) 00111 { 00112 $cli->output( "Done" ); 00113 } 00114 00115 ?>