Merge "Allow passing the default DB group to use in Maintenance scripts"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 19 Jun 2018 05:22:44 +0000 (05:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 19 Jun 2018 05:22:44 +0000 (05:22 +0000)
1  2 
includes/DefaultSettings.php
includes/libs/rdbms/lbfactory/LBFactory.php

@@@ -1894,6 -1894,11 +1894,11 @@@ $wgSQLMode = ''
   */
  $wgDBmwschema = null;
  
+ /**
+  * Default group to use when getting database connections.
+  */
+ $wgDBDefaultGroup = null;
  /**
   * To override default SQLite data directory ($docroot/../data)
   */
@@@ -4731,10 -4736,10 +4736,10 @@@ $wgPasswordDefault = 'pbkdf2'
   * $wgPasswordConfig['bcrypt-peppered'] = [
   *     'class' => EncryptedPassword::class,
   *     'underlying' => 'bcrypt',
 - *     'secrets' => [],
 - *     'cipher' => MCRYPT_RIJNDAEL_256,
 - *     'mode' => MCRYPT_MODE_CBC,
 - *     'cost' => 5,
 + *     'secrets' => [
 + *         hash( 'sha256', 'secret', true ),
 + *     ],
 + *     'cipher' => 'aes-256-cbc',
   * ];
   * @endcode
   *
@@@ -8892,17 -8897,6 +8897,17 @@@ $wgInterwikiPrefixDisplayTypes = []
   * @var int One of the MIGRATION_* constants
   */
  $wgCommentTableSchemaMigrationStage = MIGRATION_OLD;
 +
 +/**
 + * RevisionStore table schema migration stage (content, slots, content_models & slot_roles tables)
 + *
 + * @see Task: https://phabricator.wikimedia.org/T174028
 + * @see Commit: https://gerrit.wikimedia.org/r/#/c/378724/
 + *
 + * @since 1.32
 + * @var int One of the MIGRATION_* constants
 + */
 +$wgMultiContentRevisionSchemaMigrationStage = MIGRATION_OLD;
  
  /**
   * Actor table schema migration stage.
@@@ -91,6 -91,9 +91,9 @@@ abstract class LBFactory implements ILB
        /** @var string One of the ROUND_* class constants */
        private $trxRoundStage = self::ROUND_CURSORY;
  
+       /** @var string|null */
+       private $defaultGroup = null;
        const ROUND_CURSORY = 'cursory';
        const ROUND_BEGINNING = 'within-begin';
        const ROUND_COMMITTING = 'within-commit';
                $this->cliMode = $conf['cliMode'] ?? ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
                $this->hostname = $conf['hostname'] ?? gethostname();
                $this->agent = $conf['agent'] ?? '';
+               $this->defaultGroup = $conf['defaultGroup'] ?? null;
  
                $this->ticket = mt_rand();
        }
                        // Request opted out of using position wait logic. This is useful for requests
                        // done by the job queue or background ETL that do not have a meaningful session.
                        $this->chronProt->setWaitEnabled( false );
 +              } elseif ( $this->memStash instanceof EmptyBagOStuff ) {
 +                      // No where to store any DB positions and wait for them to appear
 +                      $this->chronProt->setEnabled( false );
 +                      $this->replLogger->info( 'Cannot use ChronologyProtector with EmptyBagOStuff.' );
                }
  
                $this->replLogger->debug( __METHOD__ . ': using request info ' .
                        'hostname' => $this->hostname,
                        'cliMode' => $this->cliMode,
                        'agent' => $this->agent,
+                       'defaultGroup' => $this->defaultGroup,
                        'chronologyCallback' => function ( ILoadBalancer $lb ) {
                                // Defer ChronologyProtector construction in case setRequestInfo() ends up
                                // being called later (but before the first connection attempt) (T192611)
  
        /**
         * @param string $value Possible result of LBFactory::makeCookieValueFromCPIndex()
 -       * @param int $minTimestamp Lowest UNIX timestamp of non-expired values (if present)
 +       * @param int $minTimestamp Lowest UNIX timestamp that a non-expired value can have
         * @return array (index: int or null, clientId: string or null)
         * @since 1.32
         */
        public static function getCPInfoFromCookieValue( $value, $minTimestamp ) {
                static $placeholder = [ 'index' => null, 'clientId' => null ];
  
 -              if ( !preg_match( '/^(\d+)(?:@(\d+))?(?:#([0-9a-f]{32}))?$/', $value, $m ) ) {
 +              if ( !preg_match( '/^(\d+)@(\d+)#([0-9a-f]{32})$/', $value, $m ) ) {
                        return $placeholder; // invalid
                }