Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| RebuildAll | |
100.00% |
16 / 16 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getDbType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Rebuild link tracking tables from scratch. This takes several |
| 4 | * hours, depending on the database size and server configuration. |
| 5 | * |
| 6 | * @license GPL-2.0-or-later |
| 7 | * @file |
| 8 | * @ingroup Maintenance |
| 9 | */ |
| 10 | |
| 11 | use MediaWiki\Maintenance\Maintenance; |
| 12 | |
| 13 | // @codeCoverageIgnoreStart |
| 14 | require_once __DIR__ . '/Maintenance.php'; |
| 15 | // @codeCoverageIgnoreEnd |
| 16 | |
| 17 | /** |
| 18 | * Maintenance script that rebuilds link tracking tables from scratch. |
| 19 | * |
| 20 | * @ingroup Maintenance |
| 21 | */ |
| 22 | class RebuildAll extends Maintenance { |
| 23 | public function __construct() { |
| 24 | parent::__construct(); |
| 25 | $this->addDescription( 'Rebuild links, text index and recent changes' ); |
| 26 | } |
| 27 | |
| 28 | /** @inheritDoc */ |
| 29 | public function getDbType() { |
| 30 | return Maintenance::DB_ADMIN; |
| 31 | } |
| 32 | |
| 33 | public function execute() { |
| 34 | // Rebuild the text index |
| 35 | if ( $this->getReplicaDB()->getType() != 'postgres' ) { |
| 36 | $this->output( "** Rebuilding fulltext search index (if you abort " |
| 37 | . "this will break searching; run this script again to fix):\n" ); |
| 38 | $rebuildText = $this->createChild( RebuildTextIndex::class, 'rebuildtextindex.php' ); |
| 39 | $rebuildText->execute(); |
| 40 | } |
| 41 | |
| 42 | // Rebuild RC |
| 43 | $this->output( "\n\n** Rebuilding recentchanges table:\n" ); |
| 44 | $rebuildRC = $this->createChild( RebuildRecentchanges::class, 'rebuildrecentchanges.php' ); |
| 45 | $rebuildRC->execute(); |
| 46 | |
| 47 | // Rebuild link tables |
| 48 | $this->output( "\n\n** Rebuilding links tables -- this can take a long time. " |
| 49 | . "It should be safe to abort via ctrl+C if you get bored.\n" ); |
| 50 | $rebuildLinks = $this->createChild( RefreshLinks::class, 'refreshLinks.php' ); |
| 51 | $rebuildLinks->execute(); |
| 52 | |
| 53 | $this->output( "Done.\n" ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // @codeCoverageIgnoreStart |
| 58 | $maintClass = RebuildAll::class; |
| 59 | require_once RUN_MAINTENANCE_IF_MAIN; |
| 60 | // @codeCoverageIgnoreEnd |