Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
FixTranslationNotificationsEmptyLangPrefs | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\TranslationNotifications; |
5 | |
6 | // Standard boilerplate to define $IP |
7 | use MediaWiki\Maintenance\Maintenance; |
8 | use Wikimedia\Rdbms\IExpression; |
9 | use Wikimedia\Rdbms\LikeValue; |
10 | |
11 | if ( getenv( 'MW_INSTALL_PATH' ) !== false ) { |
12 | $IP = getenv( 'MW_INSTALL_PATH' ); |
13 | } else { |
14 | $IP = __DIR__ . "/../../.."; |
15 | } |
16 | require_once "$IP/maintenance/Maintenance.php"; |
17 | /* |
18 | * This script removes the empty translationnotifications-lang-* properties. |
19 | * They became default and should not be stored. |
20 | * |
21 | * @author Amir E. Aharoni |
22 | * based on Narayam/maintenance/FixNarayamDisablePref.php |
23 | * |
24 | * @copyright Copyright © 2012 |
25 | * @license GPL-2.0-or-later |
26 | */ |
27 | |
28 | class FixTranslationNotificationsEmptyLangPrefs extends Maintenance { |
29 | |
30 | public function __construct() { |
31 | parent::__construct(); |
32 | |
33 | $this->requireExtension( 'TranslationNotifications' ); |
34 | } |
35 | |
36 | public function execute(): void { |
37 | $dbw = $this->getPrimaryDB(); |
38 | |
39 | $langPropertyPrefix = 'translationnotifications-lang-'; |
40 | $this->output( "Deleting empty {$langPropertyPrefix}* property values\n" ); |
41 | |
42 | $dbw->newDeleteQueryBuilder() |
43 | ->deleteFrom( 'user_properties' ) |
44 | ->where( |
45 | $dbw->expr( |
46 | 'up_property', |
47 | IExpression::LIKE, |
48 | new LikeValue( $langPropertyPrefix, $dbw->anyString() ) |
49 | ) |
50 | ) |
51 | ->andWhere( $dbw->expr( 'up_value', '=', '' ) ) |
52 | ->caller( __METHOD__ ) |
53 | ->execute(); |
54 | } |
55 | } |
56 | |
57 | $maintClass = FixTranslationNotificationsEmptyLangPrefs::class; |
58 | require_once RUN_MAINTENANCE_IF_MAIN; |