Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CountFancyCaptchas | |
93.75% |
15 / 16 |
|
50.00% |
1 / 2 |
4.00 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
3.03 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Counts the number of fancy captchas remaining. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | * http://www.gnu.org/copyleft/gpl.html |
| 19 | * |
| 20 | * @file |
| 21 | * @ingroup Maintenance |
| 22 | */ |
| 23 | |
| 24 | namespace MediaWiki\Extension\ConfirmEdit\Maintenance; |
| 25 | |
| 26 | // @codeCoverageIgnoreStart |
| 27 | if ( getenv( 'MW_INSTALL_PATH' ) ) { |
| 28 | $IP = getenv( 'MW_INSTALL_PATH' ); |
| 29 | } else { |
| 30 | $IP = __DIR__ . '/../../..'; |
| 31 | } |
| 32 | |
| 33 | require_once "$IP/maintenance/Maintenance.php"; |
| 34 | // @codeCoverageIgnoreEnd |
| 35 | |
| 36 | use MediaWiki\Extension\ConfirmEdit\FancyCaptcha\FancyCaptcha; |
| 37 | use MediaWiki\Extension\ConfirmEdit\Hooks; |
| 38 | use MediaWiki\Maintenance\Maintenance; |
| 39 | |
| 40 | /** |
| 41 | * Maintenance script that counts the number of captchas remaining. |
| 42 | * |
| 43 | * @ingroup Maintenance |
| 44 | */ |
| 45 | class CountFancyCaptchas extends Maintenance { |
| 46 | public function __construct() { |
| 47 | parent::__construct(); |
| 48 | $this->addDescription( "Counts the number of fancy captchas in storage" ); |
| 49 | $this->addOption( |
| 50 | 'captchastoragedir', |
| 51 | 'Overrides the value of $wgCaptchaStorageDirectory', |
| 52 | false, |
| 53 | true |
| 54 | ); |
| 55 | $this->requireExtension( "FancyCaptcha" ); |
| 56 | } |
| 57 | |
| 58 | public function execute() { |
| 59 | $instance = Hooks::getInstance(); |
| 60 | if ( !( $instance instanceof FancyCaptcha ) ) { |
| 61 | $this->fatalError( "\$wgCaptchaClass is not FancyCaptcha.\n", 1 ); |
| 62 | } |
| 63 | |
| 64 | // Overrides $wgCaptchaStorageDirectory for this script run |
| 65 | if ( $this->hasOption( 'captchastoragedir' ) ) { |
| 66 | global $wgCaptchaStorageDirectory; |
| 67 | $wgCaptchaStorageDirectory = $this->getOption( 'captchastoragedir' ); |
| 68 | } |
| 69 | |
| 70 | $countAct = $instance->getCaptchaCount(); |
| 71 | $this->output( "Current number of stored captchas is $countAct.\n" ); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // @codeCoverageIgnoreStart |
| 76 | $maintClass = CountFancyCaptchas::class; |
| 77 | require_once RUN_MAINTENANCE_IF_MAIN; |
| 78 | // @codeCoverageIgnoreEnd |