24 require_once __DIR__ .
'/Maintenance.php';
41 parent::__construct();
42 $this->
addDescription(
'Send purge requests for edits in date range to squid/varnish' );
43 $this->
addOption(
'starttime',
'Starting timestamp',
true,
true );
44 $this->
addOption(
'endtime',
'Ending timestamp',
true,
true );
45 $this->
addOption(
'htcp-dest',
'HTCP announcement destination (IP:port)',
false,
true );
46 $this->
addOption(
'sleep-per-batch',
'Milliseconds to sleep between batches',
false,
true );
47 $this->
addOption(
'dry-run',
'Do not send purge requests' );
48 $this->
addOption(
'verbose',
'Show more output',
false,
false,
'v' );
56 $parts = explode(
':', $this->
getOption(
'htcp-dest' ), 2 );
57 if ( count( $parts ) < 2 ) {
64 '' => [
'host' => $parts[0],
'port' => $parts[1] ],
67 $this->
output(
"HTCP broadcasts to {$parts[0]}:{$parts[1]}\n" );
72 $minTime =
$dbr->timestamp( $this->
getOption(
'starttime' ) );
75 if ( $maxTime < $minTime ) {
76 $this->
error(
"\nERROR: starttime after endtime\n" );
86 [
'page',
'revision' ],
93 "rev_timestamp > " .
$dbr->addQuotes( $minTime ),
94 "rev_timestamp <= " .
$dbr->addQuotes( $maxTime ),
98 "page_latest = rev_id",
101 [
'ORDER BY' =>
'rev_timestamp',
'LIMIT' => $bSize ],
103 'page' => [
'JOIN',
'rev_page=page_id' ],
107 if ( !
$res->numRows() ) {
114 if ( !count( $rows ) ) {
121 $this->
output(
"Processing changes from {$minTime} to {$lastTime}.\n" );
124 $minTime = $lastTime;
128 foreach ( $rows as $row ) {
130 $urls[] =
$title->getInternalURL();
134 $this->
output( implode(
"\n", $urls ) .
"\n" );
141 $hcu = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
142 $hcu->purgeUrls( $urls, $hcu::PURGE_NAIVE );
144 if ( $this->
hasOption(
'sleep-per-batch' ) ) {
146 usleep( 1000 * (
int)$this->
getOption(
'sleep-per-batch' ) );
150 $this->
output(
"Done!\n" );
173 $rows = iterator_to_array(
$res,
false );
180 $lastValue = end( $rows )->$column;
181 if ( count( $rows ) < $limit ) {
182 return [ $rows, $lastValue ];
185 for ( $i = count( $rows ) - 1; $i >= 0; --$i ) {
186 if ( $rows[$i]->$column !== $lastValue ) {
198 return [ $rows, end( $rows )->$column ];
203 require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
maybeHelp( $force=false)
Maybe show the help.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
Maintenance script that sends purge requests for pages edited in a date range to squid/varnish.
execute()
Do the actual work.
__construct()
Default constructor.
pageableSortedRows(IResultWrapper $res, $column, $limit)
Remove all the rows in a result set with the highest value for column $column unless the number of ro...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
$wgHTCPRouting
Config variable stub for the HTCPRouting setting, for use by phpdoc and IDEs.