Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
CleanupOrphanedTranscodes | |
0.00% |
0 / 22 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
doWork | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Re-queue selected, or all, transcodes |
4 | */ |
5 | $IP = getenv( 'MW_INSTALL_PATH' ); |
6 | if ( $IP === false ) { |
7 | $IP = __DIR__ . '/../../..'; |
8 | } |
9 | require_once "$IP/maintenance/Maintenance.php"; |
10 | |
11 | use MediaWiki\TimedMediaHandler\WebVideoTranscode\WebVideoTranscode; |
12 | |
13 | class CleanupOrphanedTranscodes extends Maintenance { |
14 | |
15 | public function __construct() { |
16 | parent::__construct(); |
17 | $this->addDescription( "remove any entries in the transcode table that do not " . |
18 | " have an associated entry in the image table." ); |
19 | $this->addOption( |
20 | 'throttle', |
21 | 'Wait this many milliseconds after each batch. Default: 200', |
22 | false, |
23 | true |
24 | ); |
25 | $this->setBatchSize( 100 ); |
26 | } |
27 | |
28 | public function execute() { |
29 | $this->output( "Cleanup transcodes:\n" ); |
30 | |
31 | $throttle = $this->getOption( 'throttle', 200 ); |
32 | $affectedRows = 0; |
33 | while ( true ) { |
34 | $batchRows = $this->doWork(); |
35 | if ( $batchRows == 0 ) { |
36 | break; |
37 | } |
38 | $this->output( ".. removed $batchRows entries...\n" ); |
39 | $affectedRows += $batchRows; |
40 | usleep( $throttle * 1000 ); |
41 | } |
42 | |
43 | $this->output( "Removed $affectedRows transcode table entries for files which do not exist.\n" ); |
44 | } |
45 | |
46 | private function doWork() { |
47 | return WebVideoTranscode::cleanupOrphanedTranscodes( $this->getBatchSize() ); |
48 | } |
49 | } |
50 | |
51 | // Tells it to run the class |
52 | $maintClass = CleanupOrphanedTranscodes::class; |
53 | require_once RUN_MAINTENANCE_IF_MAIN; |