Merge "Fixed BadMethodCallException in FileRepo for bad titles"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 10 Jul 2015 16:54:02 +0000 (16:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 10 Jul 2015 16:54:02 +0000 (16:54 +0000)
.rubocop.yml
Gruntfile.js
includes/DefaultSettings.php
includes/installer/WebInstallerPage.php
includes/password/UserPasswordPolicy.php
includes/specials/SpecialUndelete.php
tests/browser/features/step_definitions/create_account_steps.rb

index 61ffc1a..5b6c3f2 100644 (file)
@@ -1,6 +1,7 @@
 AllCops:
   Exclude:
     - 'extensions/**/*'
+    - 'node_modules/**/*'
     - 'skins/**/*'
     - 'tests/frontend/node_modules/**/*'
     - 'vendor/**/*'
index 573db69..868fa4a 100644 (file)
@@ -15,7 +15,6 @@ module.exports = function ( grunt ) {
        karmaProxy[wgScriptPath] = wgServer + wgScriptPath;
 
        grunt.initConfig( {
-               pkg: grunt.file.readJSON( 'package.json' ),
                jshint: {
                        options: {
                                jshintrc: true
index 4170c99..6050ba7 100644 (file)
@@ -6928,15 +6928,15 @@ $wgLogNames = array(
 $wgLogHeaders = array(
        '' => 'alllogstext',
        'block' => 'blocklogtext',
-       'protect' => 'protectlogtext',
-       'rights' => 'rightslogtext',
        'delete' => 'dellogpagetext',
-       'upload' => 'uploadlogpagetext',
-       'move' => 'movelogpagetext',
        'import' => 'importlogpagetext',
-       'patrol' => 'patrol-log-header',
        'merge' => 'mergelogpagetext',
+       'move' => 'movelogpagetext',
+       'patrol' => 'patrol-log-header',
+       'protect' => 'protectlogtext',
+       'rights' => 'rightslogtext',
        'suppress' => 'suppressionlogtext',
+       'upload' => 'uploadlogpagetext',
 );
 
 /**
@@ -6946,10 +6946,10 @@ $wgLogHeaders = array(
  * Extensions with custom log types may add to this array.
  */
 $wgLogActions = array(
-       'protect/protect' => 'protectedarticle',
        'protect/modify' => 'modifiedarticleprotection',
-       'protect/unprotect' => 'unprotectedarticle',
        'protect/move_prot' => 'movedarticleprotection',
+       'protect/protect' => 'protectedarticle',
+       'protect/unprotect' => 'unprotectedarticle',
 );
 
 /**
@@ -6959,35 +6959,35 @@ $wgLogActions = array(
  * @see LogFormatter
  */
 $wgLogActionsHandlers = array(
-       'move/move' => 'MoveLogFormatter',
-       'move/move_redir' => 'MoveLogFormatter',
+       'block/block' => 'BlockLogFormatter',
+       'block/reblock' => 'BlockLogFormatter',
+       'block/unblock' => 'BlockLogFormatter',
+       'contentmodel/change' => 'ContentModelLogFormatter',
        'delete/delete' => 'DeleteLogFormatter',
+       'delete/event' => 'DeleteLogFormatter',
        'delete/restore' => 'DeleteLogFormatter',
        'delete/revision' => 'DeleteLogFormatter',
-       'delete/event' => 'DeleteLogFormatter',
-       'suppress/revision' => 'DeleteLogFormatter',
-       'suppress/event' => 'DeleteLogFormatter',
-       'suppress/delete' => 'DeleteLogFormatter',
-       'patrol/patrol' => 'PatrolLogFormatter',
-       'rights/rights' => 'RightsLogFormatter',
-       'rights/autopromote' => 'RightsLogFormatter',
-       'upload/upload' => 'UploadLogFormatter',
-       'upload/overwrite' => 'UploadLogFormatter',
-       'upload/revert' => 'UploadLogFormatter',
-       'merge/merge' => 'MergeLogFormatter',
-       'tag/update' => 'TagLogFormatter',
-       'managetags/create' => 'LogFormatter',
-       'managetags/delete' => 'LogFormatter',
+       'import/interwiki' => 'LogFormatter',
+       'import/upload' => 'LogFormatter',
        'managetags/activate' => 'LogFormatter',
+       'managetags/create' => 'LogFormatter',
        'managetags/deactivate' => 'LogFormatter',
-       'block/block' => 'BlockLogFormatter',
-       'block/unblock' => 'BlockLogFormatter',
-       'block/reblock' => 'BlockLogFormatter',
+       'managetags/delete' => 'LogFormatter',
+       'merge/merge' => 'MergeLogFormatter',
+       'move/move' => 'MoveLogFormatter',
+       'move/move_redir' => 'MoveLogFormatter',
+       'patrol/patrol' => 'PatrolLogFormatter',
+       'rights/autopromote' => 'RightsLogFormatter',
+       'rights/rights' => 'RightsLogFormatter',
        'suppress/block' => 'BlockLogFormatter',
+       'suppress/delete' => 'DeleteLogFormatter',
+       'suppress/event' => 'DeleteLogFormatter',
        'suppress/reblock' => 'BlockLogFormatter',
-       'import/upload' => 'LogFormatter',
-       'import/interwiki' => 'LogFormatter',
-       'contentmodel/change' => 'ContentModelLogFormatter',
+       'suppress/revision' => 'DeleteLogFormatter',
+       'tag/update' => 'TagLogFormatter',
+       'upload/overwrite' => 'UploadLogFormatter',
+       'upload/revert' => 'UploadLogFormatter',
+       'upload/upload' => 'UploadLogFormatter',
 );
 
 /**
index f40de71..9aa6960 100644 (file)
@@ -833,6 +833,8 @@ class WebInstallerName extends WebInstallerPage {
         * @return bool
         */
        public function submit() {
+               global $wgPasswordPolicy;
+
                $retVal = true;
                $this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
                        '_AdminName', '_AdminPassword', '_AdminPasswordConfirm', '_AdminEmail',
@@ -909,7 +911,16 @@ class WebInstallerName extends WebInstallerPage {
                $pwd = $this->getVar( '_AdminPassword' );
                $user = User::newFromName( $cname );
                if ( $user ) {
-                       $valid = $user->getPasswordValidity( $pwd );
+                       $upp = new UserPasswordPolicy(
+                               $wgPasswordPolicy['policies'],
+                               $wgPasswordPolicy['checks']
+                       );
+                       $status = $upp->checkUserPasswordForGroups(
+                               $user,
+                               $pwd,
+                               array( 'sysop', 'bureaucrat' )
+                       );
+                       $valid = $status->isGood();
                } else {
                        $valid = 'config-admin-name-invalid';
                }
index cdad9ba..70757ac 100644 (file)
@@ -72,22 +72,53 @@ class UserPasswordPolicy {
         */
        public function checkUserPassword( User $user, $password ) {
                $effectivePolicy = $this->getPoliciesForUser( $user );
-               $status = Status::newGood();
+               return $this->checkPolicies(
+                       $user,
+                       $password,
+                       $effectivePolicy,
+                       $this->policyCheckFunctions
+               );
+       }
+
+       /**
+        * Check if a passwords meets the effective password policy for a User, using a set
+        * of groups they may or may not belong to. This function does not use the DB, so can
+        * be used in the installer.
+        * @param User $user who's policy we are checking
+        * @param string $password the password to check
+        * @param array $groups list of groups to which we assume the user belongs
+        * @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 checkUserPasswordForGroups( User $user, $password, array $groups ) {
+               $effectivePolicy = self::getPoliciesForGroups(
+                       $this->policies,
+                       $groups,
+                       $this->policies['default']
+               );
+               return $this->checkPolicies(
+                       $user,
+                       $password,
+                       $effectivePolicy,
+                       $this->policyCheckFunctions
+               );
+       }
 
-               foreach ( $effectivePolicy as $policy => $value ) {
-                       if ( !isset( $this->policyCheckFunctions[$policy] ) ) {
+       private function checkPolicies( User $user, $password, $policies, $policyCheckFunctions ) {
+               $status = Status::newGood();
+               foreach ( $policies as $policy => $value ) {
+                       if ( !isset( $policyCheckFunctions[$policy] ) ) {
                                throw new DomainException( 'Invalid password policy config' );
                        }
                        $status->merge(
                                call_user_func(
-                                       $this->policyCheckFunctions[$policy],
+                                       $policyCheckFunctions[$policy],
                                        $value,
                                        $user,
                                        $password
                                )
                        );
                }
-
                return $status;
        }
 
index 5732ef9..d7e75bc 100644 (file)
@@ -149,7 +149,8 @@ class PageArchive {
                        $fields,
                        $conds,
                        $join_conds,
-                       $options
+                       $options,
+                       ''
                );
 
                return $dbr->select( $tables,
index 3d312f7..98e0f2c 100644 (file)
@@ -22,5 +22,5 @@ When(/^I submit the form$/) do
 end
 
 Then(/^an error message is displayed$/) do
-  expect(on(CreateAccountPage).error_message_element.class_name).to eq "errorbox"
+  expect(on(CreateAccountPage).error_message_element.class_name).to eq 'errorbox'
 end