Merge "tests: Throw when tests run that "need a db" but miss Database group"
[lhc/web/wiklou.git] / maintenance / wrapOldPasswords.php
index 6a601ad..ef9e46e 100644 (file)
@@ -1,7 +1,4 @@
 <?php
-
-use MediaWiki\MediaWikiServices;
-
 /**
  * Maintenance script to wrap all old-style passwords in a layered type
  *
@@ -23,8 +20,11 @@ use MediaWiki\MediaWikiServices;
  * @file
  * @ingroup Maintenance
  */
+
 require_once __DIR__ . '/Maintenance.php';
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Maintenance script to wrap all passwords of a certain type in a specified layered
  * type that wraps around the old type.
@@ -43,20 +43,19 @@ class WrapOldPasswords extends Maintenance {
        }
 
        public function execute() {
-               $passwordFactory = new PasswordFactory();
-               $passwordFactory->init( RequestContext::getMain()->getConfig() );
+               $passwordFactory = MediaWikiServices::getInstance()->getPasswordFactory();
 
                $typeInfo = $passwordFactory->getTypes();
                $layeredType = $this->getOption( 'type' );
 
                // Check that type exists and is a layered type
                if ( !isset( $typeInfo[$layeredType] ) ) {
-                       $this->error( 'Undefined password type', true );
+                       $this->fatalError( 'Undefined password type' );
                }
 
                $passObj = $passwordFactory->newFromType( $layeredType );
                if ( !$passObj instanceof LayeredParameterizedPassword ) {
-                       $this->error( 'Layered parameterized password type must be used.', true );
+                       $this->fatalError( 'Layered parameterized password type must be used.' );
                }
 
                // Extract the first layer type
@@ -121,5 +120,5 @@ class WrapOldPasswords extends Maintenance {
        }
 }
 
-$maintClass = "WrapOldPasswords";
+$maintClass = WrapOldPasswords::class;
 require_once RUN_MAINTENANCE_IF_MAIN;