Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Purge | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\ReadingLists\Maintenance; |
4 | |
5 | use Maintenance; |
6 | use MediaWiki\Extension\ReadingLists\Utils; |
7 | |
8 | require_once getenv( 'MW_INSTALL_PATH' ) !== false |
9 | ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php' |
10 | : __DIR__ . '/../../../maintenance/Maintenance.php'; |
11 | |
12 | /** |
13 | * Maintenance script for purging unneeded DB rows (deleted lists/entries or orphaned sortkeys). |
14 | * Purging deleted lists/entries limits clients' ability to sync deletes. |
15 | * Purging orphaned sortkeys has no user-visible effect. |
16 | * @ingroup Maintenance |
17 | */ |
18 | class Purge extends Maintenance { |
19 | |
20 | public function __construct() { |
21 | parent::__construct(); |
22 | $this->addDescription( |
23 | 'Purge unneeded database rows (deleted lists/entries or orphaned sortkeys).' ); |
24 | $this->addOption( 'before', 'Purge deleted lists/entries before this timestamp', false, true ); |
25 | $this->requireExtension( 'ReadingLists' ); |
26 | } |
27 | |
28 | /** |
29 | * @inheritDoc |
30 | */ |
31 | public function execute() { |
32 | $now = wfTimestampNow(); |
33 | if ( $this->hasOption( 'before' ) ) { |
34 | $before = wfTimestamp( TS_MW, $this->getOption( 'before' ) ); |
35 | if ( !$before || $now <= $before ) { |
36 | // Let's not delete all rows if the user entered an invalid timestamp. |
37 | $this->fatalError( 'Invalid timestamp' ); |
38 | } |
39 | } else { |
40 | $before = Utils::getDeletedExpiry(); |
41 | } |
42 | $this->output( "...purging deleted rows\n" ); |
43 | Utils::makeMaintenanceRepository()->purgeOldDeleted( $before ); |
44 | $this->output( "done.\n" ); |
45 | } |
46 | |
47 | } |
48 | |
49 | $maintClass = Purge::class; |
50 | require_once RUN_MAINTENANCE_IF_MAIN; |