Merge "Remove Atomic methods from ConnectionManagers"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 2 Dec 2016 05:07:53 +0000 (05:07 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 2 Dec 2016 05:07:53 +0000 (05:07 +0000)
docs/hooks.txt
includes/password/UserPasswordPolicy.php
includes/specials/SpecialFewestrevisions.php
includes/user/User.php
maintenance/mergeMessageFileList.php
tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php

index a73d50f..da12d8c 100644 (file)
@@ -2554,8 +2554,6 @@ $user: the User considering the edit
 'PasswordPoliciesForUser': Alter the effective password policy for a user.
 $user: User object whose policy you are modifying
 &$effectivePolicy: Array of policy statements that apply to this user
-$purpose: string indicating purpose of the check, one of 'login', 'create',
-  or 'reset'
 
 'PerformRetroactiveAutoblock': Called before a retroactive autoblock is applied
 to a user.
index 5584f6f..bf1f8ac 100644 (file)
@@ -67,12 +67,11 @@ class UserPasswordPolicy {
         * Check if a passwords meets the effective password policy for a User.
         * @param User $user who's policy we are checking
         * @param string $password the password to check
-        * @param string $purpose one of 'login', 'create', 'reset'
         * @return Status error to indicate the password didn't meet the policy, or fatal to
         *      indicate the user shouldn't be allowed to login.
         */
-       public function checkUserPassword( User $user, $password, $purpose = 'login' ) {
-               $effectivePolicy = $this->getPoliciesForUser( $user, $purpose );
+       public function checkUserPassword( User $user, $password ) {
+               $effectivePolicy = $this->getPoliciesForUser( $user );
                return $this->checkPolicies(
                        $user,
                        $password,
@@ -134,20 +133,16 @@ class UserPasswordPolicy {
         * Get the policy for a user, based on their group membership. Public so
         * UI elements can access and inform the user.
         * @param User $user
-        * @param string $purpose one of 'login', 'create', 'reset'
         * @return array the effective policy for $user
         */
-       public function getPoliciesForUser( User $user, $purpose = 'login' ) {
-               $effectivePolicy = $this->policies['default'];
-               if ( $purpose !== 'create' ) {
-                       $effectivePolicy = self::getPoliciesForGroups(
-                               $this->policies,
-                               $user->getEffectiveGroups(),
-                               $this->policies['default']
-                       );
-               }
+       public function getPoliciesForUser( User $user ) {
+               $effectivePolicy = self::getPoliciesForGroups(
+                       $this->policies,
+                       $user->getEffectiveGroups(),
+                       $this->policies['default']
+               );
 
-               Hooks::run( 'PasswordPoliciesForUser', [ $user, &$effectivePolicy, $purpose ] );
+               Hooks::run( 'PasswordPoliciesForUser', [ $user, &$effectivePolicy ] );
 
                return $effectivePolicy;
        }
index d7879ff..f20829f 100644 (file)
@@ -53,12 +53,6 @@ class FewestrevisionsPage extends QueryPage {
                                'page_namespace' => MWNamespace::getContentNamespaces(),
                                'page_id = rev_page' ],
                        'options' => [
-                               'HAVING' => 'COUNT(*) > 1',
-                               // ^^^ This was probably here to weed out redirects.
-                               // Since we mark them as such now, it might be
-                               // useful to remove this. People _do_ create pages
-                               // and never revise them, they aren't necessarily
-                               // redirects.
                                'GROUP BY' => [ 'page_namespace', 'page_title', 'page_is_redirect' ]
                        ]
                ];
index f07db0e..26f1040 100644 (file)
@@ -1003,11 +1003,10 @@ class User implements IDBAccessObject {
         * able to set their password to this.
         *
         * @param string $password Desired password
-        * @param string $purpose one of 'login', 'create', 'reset'
         * @return Status
         * @since 1.23
         */
-       public function checkPasswordValidity( $password, $purpose = 'login' ) {
+       public function checkPasswordValidity( $password ) {
                global $wgPasswordPolicy;
 
                $upp = new UserPasswordPolicy(
@@ -1024,7 +1023,7 @@ class User implements IDBAccessObject {
                }
 
                if ( $result === false ) {
-                       $status->merge( $upp->checkUserPassword( $this, $password, $purpose ) );
+                       $status->merge( $upp->checkUserPassword( $this, $password ) );
                        return $status;
                } elseif ( $result === true ) {
                        return $status;
index a650aa0..bb47631 100644 (file)
@@ -36,11 +36,6 @@ $mmfl = false;
  * @ingroup Maintenance
  */
 class MergeMessageFileList extends Maintenance {
-       /**
-        * @var bool
-        */
-       protected $hasError;
-
        function __construct() {
                parent::__construct();
                $this->addOption(
@@ -106,7 +101,6 @@ class MergeMessageFileList extends Maintenance {
                                }
 
                                if ( !$found ) {
-                                       $this->hasError = true;
                                        $this->error( "Extension {$extname} in {$extdir} lacks expected entry point: " .
                                                "extension.json, skin.json, or {$extname}.php." );
                                }
@@ -119,10 +113,6 @@ class MergeMessageFileList extends Maintenance {
                        $mmfl['setupFiles'] = array_merge( $mmfl['setupFiles'], $extensionPaths );
                }
 
-               if ( $this->hasError ) {
-                       $this->error( "Some files are missing (see above). Giving up.", 1 );
-               }
-
                if ( $this->hasOption( 'output' ) ) {
                        $mmfl['output'] = $this->getOption( 'output' );
                }
index 1093039..baf0b69 100644 (file)
@@ -104,4 +104,13 @@ class ResourceLoaderContextTest extends PHPUnit_Framework_TestCase {
                $this->assertSame( 'Example', $ctx->getUser() );
                $this->assertEquals( 'Example', $ctx->getUserObj()->getName() );
        }
+
+       public function testMsg() {
+               $ctx = new ResourceLoaderContext( $this->getResourceLoader(), new FauxRequest( [
+                       'lang' => 'en'
+               ] ) );
+               $msg = $ctx->msg( 'mainpage' );
+               $this->assertInstanceOf( Message::class, $msg );
+               $this->assertSame( 'Main Page', $msg->useDatabase( false )->plain() );
+       }
 }