Merge "Use ParserCache in CategoryMembershipChangeJob"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 29 Nov 2018 01:15:01 +0000 (01:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 29 Nov 2018 01:15:01 +0000 (01:15 +0000)
1  2 
includes/DefaultSettings.php
includes/Storage/DerivedPageDataUpdater.php

@@@ -37,6 -37,7 +37,7 @@@
   *
   * @file
   */
+ use MediaWiki\MediaWikiServices;
  
  /**
   * @cond file_level_code
@@@ -4520,8 -4521,6 +4521,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',
        ],
  ];
  
@@@ -7565,7 -7558,10 +7566,10 @@@ $wgJobClasses = 
        'refreshLinksPrioritized' => RefreshLinksJob::class,
        'refreshLinksDynamic' => RefreshLinksJob::class,
        'activityUpdateJob' => ActivityUpdateJob::class,
-       'categoryMembershipChange' => CategoryMembershipChangeJob::class,
+       'categoryMembershipChange' => function ( Title $title, $params = [] ) {
+               $pc = MediaWikiServices::getInstance()->getParserCache();
+               return new CategoryMembershipChangeJob( $pc, $title, $params );
+       },
        'clearUserWatchlist' => ClearUserWatchlistJob::class,
        'cdnPurge' => CdnPurgeJob::class,
        'userGroupExpiry' => UserGroupExpiryJob::class,
@@@ -8931,9 -8927,6 +8935,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,
  ];
  
  /**
@@@ -8989,7 -8982,7 +8993,7 @@@ $wgInterwikiPrefixDisplayTypes = []
   * @since 1.30
   * @var int One of the MIGRATION_* constants
   */
 -$wgCommentTableSchemaMigrationStage = MIGRATION_OLD;
 +$wgCommentTableSchemaMigrationStage = MIGRATION_NEW;
  
  /**
   * RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables).
@@@ -9031,24 -9024,40 +9035,24 @@@ $wgMultiContentRevisionSchemaMigrationS
  $wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_OLD;
  
  /**
 - * change_tag table schema migration stage.
 - *
 - * - MIGRATION_OLD: Do not use change_tag_def table or ct_tag_id.
 - * - MIGRATION_WRITE_BOTH: Write to the change_tag_def table and ct_tag_id, but read from
 - *   the old schema. This is different from the formal definition of the constants
 - * - MIGRATION_WRITE_NEW: Behaves the same as MIGRATION_WRITE_BOTH
 - * - MIGRATION_NEW: Use the change_tag_def table and ct_tag_id, do not read/write ct_tag
 - *
 - * @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
 + * Flag to enable Partial Blocks. This allows an admin to prevent a user from editing specific pages
 + * or namespaces.
   *
   * @since 1.32
 + * @deprecated 1.32
   * @var bool
   */
 -$wgTagStatisticsNewTable = false;
 +$wgEnablePartialBlocks = false;
  
  /**
 - * Flag to enable Partial Blocks. This allows an admin to prevent a user from editing specific pages
 - * or namespaces.
 + * Enable stats monitoring when Block Notices are displayed in different places around core
 + * and extensions.
   *
 - * @since 1.32
 - * @deprecated 1.32
 + * @since 1.34
 + * @deprecated 1.34
   * @var bool
   */
 -$wgEnablePartialBlocks = false;
 +$wgEnableBlockNoticeStats = false;
  
  /**
   * For really cool vim folding this needs to be at the end:
@@@ -351,9 -351,13 +351,9 @@@ class DerivedPageDataUpdater implement
                        throw new InvalidArgumentException( '$parentId should match the parent of $revision' );
                }
  
 -              if ( $revision
 -                      && $user
 -                      && $revision->getUser( RevisionRecord::RAW )->getName() !== $user->getName()
 -              ) {
 -                      throw new InvalidArgumentException( '$user should match the author of $revision' );
 -              }
 -
 +              // NOTE: For null revisions, $user may be different from $this->revision->getUser
 +              // and also from $revision->getUser.
 +              // But $user should always match $this->user.
                if ( $user && $this->user && $user->getName() !== $this->user->getName() ) {
                        return false;
                }
                        return false;
                }
  
 -              if ( $revision && !$user ) {
 -                      $user = $revision->getUser( RevisionRecord::RAW );
 -              }
 -
                if ( $this->pageState
                        && $revision
                        && $revision->getParentId() !== null
                        return false;
                }
  
 -              if ( $this->revision
 -                      && $user
 -                      && $this->revision->getUser( RevisionRecord::RAW )
 -                      && $this->revision->getUser( RevisionRecord::RAW )->getName() !== $user->getName()
 -              ) {
 -                      return false;
 -              }
 -
 -              if ( $revision
 -                      && $this->user
 -                      && $this->revision->getUser( RevisionRecord::RAW )
 -                      && $revision->getUser( RevisionRecord::RAW )->getName() !== $this->user->getName()
 -              ) {
 -                      return false;
 -              }
 -
                // NOTE: this check is the primary reason for having the $this->slotsUpdate field!
                if ( $this->slotsUpdate
                        && $slotsUpdate
                        $stashedEdit = ApiStashEdit::checkCache( $title, $mainContent, $legacyUser );
                }
  
 -              if ( $stashedEdit ) {
 -                      /** @var ParserOutput $output */
 -                      $output = $stashedEdit->output;
 -
 -                      // TODO: this should happen when stashing the ParserOutput, not now!
 -                      $output->setCacheTime( $stashedEdit->timestamp );
 -
 -                      // TODO: MCR: allow output for all slots to be stashed.
 -                      $this->canonicalParserOutput = $output;
 -              }
 -
                $userPopts = ParserOptions::newFromUserAndLang( $user, $this->contLang );
                Hooks::run( 'ArticlePrepareTextForEdit', [ $wikiPage, $userPopts ] );
  
                } else {
                        $this->parentRevision = $parentRevision;
                }
 +
 +              $renderHints = [ 'use-master' => $this->useMaster(), 'audience' => RevisionRecord::RAW ];
 +
 +              if ( $stashedEdit ) {
 +                      /** @var ParserOutput $output */
 +                      $output = $stashedEdit->output;
 +
 +                      // TODO: this should happen when stashing the ParserOutput, not now!
 +                      $output->setCacheTime( $stashedEdit->timestamp );
 +
 +                      $renderHints['known-revision-output'] = $output;
 +              }
 +
 +              // NOTE: we want a canonical rendering, so don't pass $this->user or ParserOptions
 +              // NOTE: the revision is either new or current, so we can bypass audience checks.
 +              $this->renderedRevision = $this->revisionRenderer->getRenderedRevision(
 +                      $this->revision,
 +                      null,
 +                      null,
 +                      $renderHints
 +              );
        }
  
        /**
         * @return RenderedRevision
         */
        public function getRenderedRevision() {
 -              if ( !$this->renderedRevision ) {
 -                      $this->assertPrepared( __METHOD__ );
 -
 -                      // NOTE: we want a canonical rendering, so don't pass $this->user or ParserOptions
 -                      // NOTE: the revision is either new or current, so we can bypass audience checks.
 -                      $this->renderedRevision = $this->revisionRenderer->getRenderedRevision(
 -                              $this->revision,
 -                              null,
 -                              null,
 -                              [ 'use-master' => $this->useMaster(), 'audience' => RevisionRecord::RAW ]
 -                      );
 -              }
 +              $this->assertPrepared( __METHOD__ );
  
                return $this->renderedRevision;
        }
                // Prune any output that depends on the revision ID.
                if ( $this->renderedRevision ) {
                        $this->renderedRevision->updateRevision( $revision );
 +              } else {
 +
 +                      // NOTE: we want a canonical rendering, so don't pass $this->user or ParserOptions
 +                      // NOTE: the revision is either new or current, so we can bypass audience checks.
 +                      $this->renderedRevision = $this->revisionRenderer->getRenderedRevision(
 +                              $this->revision,
 +                              null,
 +                              null,
 +                              [ 'use-master' => $this->useMaster(), 'audience' => RevisionRecord::RAW ]
 +                      );
 +
 +                      // XXX: Since we presumably are dealing with the current revision,
 +                      // we could try to get the ParserOutput from the parser cache.
                }
  
                // TODO: optionally get ParserOutput from the ParserCache here.
                        // the recent change entry (also done via deferred updates) and carry over any
                        // bot/deletion/IP flags, ect.
                        $this->jobQueueGroup->lazyPush(
-                               new CategoryMembershipChangeJob(
+                               CategoryMembershipChangeJob::newSpec(
                                        $this->getTitle(),
-                                       [
-                                               'pageId' => $this->getPageId(),
-                                               'revTimestamp' => $this->revision->getTimestamp(),
-                                       ]
+                                       $this->revision->getTimestamp()
                                )
                        );
                }