Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| PurgeRecentChanges | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | use MediaWiki\Maintenance\Maintenance; |
| 8 | use MediaWiki\RecentChanges\RecentChangesUpdateJob; |
| 9 | |
| 10 | // @codeCoverageIgnoreStart |
| 11 | require_once __DIR__ . '/Maintenance.php'; |
| 12 | // @codeCoverageIgnoreEnd |
| 13 | |
| 14 | /** |
| 15 | * Purge rows from the recentchanges table older than wgRCMaxAge. |
| 16 | * |
| 17 | * Useful to run on wikis which are infrequently edited and therefore RecentChangesUpdateJob |
| 18 | * may not be run frequently enough. |
| 19 | * |
| 20 | * @ingroup RecentChanges |
| 21 | * @ingroup Maintenance |
| 22 | * @since 1.43 |
| 23 | */ |
| 24 | class PurgeRecentChanges extends Maintenance { |
| 25 | public function __construct() { |
| 26 | parent::__construct(); |
| 27 | $this->addDescription( 'Purge rows from the recentchanges table which are older than wgRCMaxAge.' ); |
| 28 | } |
| 29 | |
| 30 | public function execute() { |
| 31 | // Run directly instead of pushing to the job queue, so that the script will exit only once the |
| 32 | // purge is complete. If a job is already running to do the purge, then the script will exit early. |
| 33 | // However, this is fine because a purge is already in progress. |
| 34 | $recentChangesPruneJob = RecentChangesUpdateJob::newPurgeJob(); |
| 35 | $recentChangesPruneJob->run(); |
| 36 | $this->output( "Finished purging data from recentchanges.\n" ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // @codeCoverageIgnoreStart |
| 41 | $maintClass = PurgeRecentChanges::class; |
| 42 | require_once RUN_MAINTENANCE_IF_MAIN; |
| 43 | // @codeCoverageIgnoreEnd |