3 require( dirname( __FILE__
) . '/Maintenance.php' );
5 class PurgeParserCache
extends Maintenance
{
6 function __construct() {
8 $this->addDescription( "Remove old objects from the parser cache. " .
9 "This only works when the parser cache is in an SQL database." );
10 $this->addOption( 'expiredate', 'Delete objects expiring before this date.', false, true );
11 $this->addOption( 'age',
12 'Delete objects created more than this many seconds ago, assuming $wgParserCacheExpireTime '.
13 'has been consistent.',
18 $inputDate = $this->getOption( 'expiredate' );
19 $inputAge = $this->getOption( 'age' );
20 if ( $inputDate !== null ) {
21 $date = wfTimestamp( TS_MW
, strtotime( $inputDate ) );
22 } elseif ( $inputAge !== null ) {
23 global $wgParserCacheExpireTime;
24 $date = wfTimestamp( TS_MW
, time() +
$wgParserCacheExpireTime - intval( $inputAge ) );
26 echo "Must specify either --expiredate or --age\n";
30 $english = Language
::factory( 'en' );
31 echo "Deleting objects expiring before " . $english->timeanddate( $date ) . "\n";
33 $pc = wfGetParserCacheStorage();
34 $success = $pc->deleteObjectsExpiringBefore( $date );
36 echo "Cannot purge this kind of parser cache.\n";
42 $maintClass = 'PurgeParserCache';
43 require_once( RUN_MAINTENANCE_IF_MAIN
);