Merge "Add block notice stats on EditPage."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 28 Nov 2018 19:55:12 +0000 (19:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 28 Nov 2018 19:55:12 +0000 (19:55 +0000)
1  2 
includes/DefaultSettings.php
includes/EditPage.php

@@@ -4520,8 -4520,6 +4520,8 @@@ $wgCentralIdLookupProvider = 'local'
   *            commonly chosen. Set to integer n to ban the top n passwords.
   *            If you want to ban all common passwords on file, use the
   *            PHP_INT_MAX constant.
 + *    - PasswordNotInLargeBlacklist - Password not in best practices list of
 + *            100,000 commonly used passwords.
   * @since 1.26
   */
  $wgPasswordPolicy = [
                        'MinimumPasswordLengthToLogin' => 1,
                        'PasswordCannotMatchUsername' => true,
                        'PasswordCannotBePopular' => 25,
 +                      'PasswordNotInLargeBlacklist' => true,
                ],
                'sysop' => [
                        'MinimalPasswordLength' => 8,
                        'MinimumPasswordLengthToLogin' => 1,
                        'PasswordCannotMatchUsername' => true,
                        'PasswordCannotBePopular' => 25,
 +                      'PasswordNotInLargeBlacklist' => true,
                ],
                'interface-admin' => [
                        'MinimalPasswordLength' => 8,
                        'MinimumPasswordLengthToLogin' => 1,
                        'PasswordCannotMatchUsername' => true,
                        'PasswordCannotBePopular' => 25,
 +                      'PasswordNotInLargeBlacklist' => true,
                ],
                'bot' => [
                        'MinimalPasswordLength' => 8,
                        'MinimumPasswordLengthToLogin' => 1,
                        'PasswordCannotMatchUsername' => true,
 +                      'PasswordNotInLargeBlacklist' => true,
                ],
                'default' => [
                        'MinimalPasswordLength' => 1,
                        'PasswordCannotMatchUsername' => true,
                        'PasswordCannotMatchBlacklist' => true,
                        'MaximalPasswordLength' => 4096,
 +                      'PasswordNotInLargeBlacklist' => false,
                ],
        ],
        'checks' => [
                'PasswordCannotMatchUsername' => 'PasswordPolicyChecks::checkPasswordCannotMatchUsername',
                'PasswordCannotMatchBlacklist' => 'PasswordPolicyChecks::checkPasswordCannotMatchBlacklist',
                'MaximalPasswordLength' => 'PasswordPolicyChecks::checkMaximalPasswordLength',
 -              'PasswordCannotBePopular' => 'PasswordPolicyChecks::checkPopularPasswordBlacklist'
 +              'PasswordCannotBePopular' => 'PasswordPolicyChecks::checkPopularPasswordBlacklist',
 +              'PasswordNotInLargeBlacklist' => 'PasswordPolicyChecks::checkPasswordNotInLargeBlacklist',
        ],
  ];
  
@@@ -8931,9 -8923,6 +8931,9 @@@ $wgCSPFalsePositiveUrls = 
        'https://rtb.metrigo.com' => true,
        'https://d5p.de17a.com' => true,
        'https://ad.lkqd.net/vpaid/vpaid.js' => true,
 +      'https://ad.lkqd.net/vpaid/vpaid.js?fusion=1.0' => true,
 +      'https://t.lkqd.net/t' => true,
 +      'chrome-extension' => true,
  ];
  
  /**
@@@ -9042,7 -9031,19 +9042,7 @@@ $wgActorTableSchemaMigrationStage = SCH
   * @since 1.32
   * @var int One of the MIGRATION_* constants
   */
 -$wgChangeTagsSchemaMigrationStage = MIGRATION_WRITE_BOTH;
 -
 -/**
 - * Temporarily flag to use change_tag_def table as backend of change tag statistics.
 - * For example in case of Special:Tags. If set to false, it will use change_tag table.
 - * Before setting it to true set $wgChangeTagsSchemaMigrationStage to MIGRATION_WRITE_BOTH and run
 - * PopulateChangeTagDef maintaince script.
 - * It's redundant when $wgChangeTagsSchemaMigrationStage is set to MIGRATION_NEW
 - *
 - * @since 1.32
 - * @var bool
 - */
 -$wgTagStatisticsNewTable = false;
 +$wgChangeTagsSchemaMigrationStage = MIGRATION_NEW;
  
  /**
   * Flag to enable Partial Blocks. This allows an admin to prevent a user from editing specific pages
   */
  $wgEnablePartialBlocks = false;
  
+ /**
+  * Enable stats monitoring when Block Notices are displayed in different places around core
+  * and extensions.
+  *
+  * @since 1.34
+  * @deprecated 1.34
+  * @var bool
+  */
+ $wgEnableBlockNoticeStats = false;
  /**
   * For really cool vim folding this needs to be at the end:
   * vim: foldmarker=@{,@} foldmethod=marker
diff --combined includes/EditPage.php
@@@ -476,15 -476,7 +476,15 @@@ class EditPage 
                $this->mArticle = $article;
                $this->page = $article->getPage(); // model object
                $this->mTitle = $article->getTitle();
 -              $this->context = $article->getContext();
 +
 +              // Make sure the local context is in sync with other member variables.
 +              // Particularly make sure everything is using the same WikiPage instance.
 +              // This should probably be the case in Article as well, but it's
 +              // particularly important for EditPage, to make use of the in-place caching
 +              // facility in WikiPage::prepareContentForEdit.
 +              $this->context = new DerivativeContext( $article->getContext() );
 +              $this->context->setWikiPage( $this->page );
 +              $this->context->setTitle( $this->mTitle );
  
                $this->contentModel = $this->mTitle->getContentModel();
  
                if ( $permErrors ) {
                        wfDebug( __METHOD__ . ": User can't edit\n" );
  
-                       // track block with a cookie if it doesn't exists already
-                       $this->context->getUser()->trackBlockWithCookie();
-                       // Auto-block user's IP if the account was "hard" blocked
-                       if ( !wfReadOnly() ) {
-                               DeferredUpdates::addCallableUpdate( function () {
-                                       $this->context->getUser()->spreadAnyEditBlock();
-                               } );
+                       if ( $this->context->getUser()->getBlock() ) {
+                               // track block with a cookie if it doesn't exists already
+                               $this->context->getUser()->trackBlockWithCookie();
+                               // Auto-block user's IP if the account was "hard" blocked
+                               if ( !wfReadOnly() ) {
+                                       DeferredUpdates::addCallableUpdate( function () {
+                                               $this->context->getUser()->spreadAnyEditBlock();
+                                       } );
+                               }
+                               $config = $this->context->getConfig();
+                               if ( $config->get( 'EnableBlockNoticeStats' ) ) {
+                                       $wiki = $config->get( 'DBname' );
+                                       $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
+                                       $statsd->increment( 'BlockNotices.' . $wiki . '.WikitextEditor.shown' );
+                               }
                        }
                        $this->displayPermissionsError( $permErrors );
  
@@@ -3131,10 -3132,7 +3140,10 @@@ ERROR
  
                                        if ( !$revision->isCurrent() ) {
                                                $this->mArticle->setOldSubtitle( $revision->getId() );
 -                                              $out->addWikiMsg( 'editingold' );
 +                                              $out->wrapWikiMsg(
 +                                                      Html::warningBox( "\n$1\n" ),
 +                                                      'editingold'
 +                                              );
                                                $this->isOldRev = true;
                                        }
                                } elseif ( $this->mTitle->exists() ) {
                        );
                } elseif ( $user->isAnon() ) {
                        if ( $this->formtype != 'preview' ) {
 +                              $returntoquery = array_diff_key(
 +                                      $this->context->getRequest()->getValues(),
 +                                      [ 'title' => true, 'returnto' => true, 'returntoquery' => true ]
 +                              );
                                $out->wrapWikiMsg(
                                        "<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
                                        [ 'anoneditwarning',
                                                // Log-in link
                                                SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [
 -                                                      'returnto' => $this->getTitle()->getPrefixedDBkey()
 +                                                      'returnto' => $this->getTitle()->getPrefixedDBkey(),
 +                                                      'returntoquery' => wfArrayToCgi( $returntoquery ),
                                                ] ),
                                                // Sign-up link
                                                SpecialPage::getTitleFor( 'CreateAccount' )->getFullURL( [
 -                                                      'returnto' => $this->getTitle()->getPrefixedDBkey()
 +                                                      'returnto' => $this->getTitle()->getPrefixedDBkey(),
 +                                                      'returntoquery' => wfArrayToCgi( $returntoquery ),
                                                ] )
                                        ]
                                );