Merge "Improve safeGetLag() return docs"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 30 Jan 2016 13:35:39 +0000 (13:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 30 Jan 2016 13:35:39 +0000 (13:35 +0000)
16 files changed:
RELEASE-NOTES-1.27
includes/api/ApiBase.php
includes/api/ApiQuerySiteinfo.php
includes/db/loadbalancer/LoadBalancer.php
includes/logging/LogFormatter.php
includes/mail/EmailNotification.php
includes/session/SessionBackend.php
includes/session/SessionManager.php
includes/specials/SpecialVersion.php
languages/i18n/en.json
languages/i18n/qqq.json
tests/phpunit/includes/session/CookieSessionProviderTest.php
tests/phpunit/includes/session/ImmutableSessionProviderWithCookieTest.php
tests/phpunit/includes/session/PHPSessionHandlerTest.php
tests/phpunit/includes/session/SessionBackendTest.php
tests/phpunit/includes/session/SessionManagerTest.php

index 35ce6c2..c5356c1 100644 (file)
@@ -209,6 +209,7 @@ production.
 * ApiQueryBase::getDirectionDescription() was removed (deprecated since 1.25).
 * ApiQuery::getModules() was removed (deprecated since 1.21).
 * ApiMain::getModules() was removed (deprecated since 1.21).
+* ApiBase::getVersion() was removed (deprecated since 1.21).
 
 === Languages updated in 1.27 ===
 
index 425a337..02720c0 100644 (file)
@@ -2522,19 +2522,6 @@ abstract class ApiBase extends ContextSource {
        /// @deprecated since 1.24
        const PROP_NULLABLE = 1;
 
-       /**
-        * Formerly returned a string that identifies the version of the extending
-        * class. Typically included the class name, the svn revision, timestamp,
-        * and last author. Usually done with SVN's Id keyword
-        *
-        * @deprecated since 1.21, version string is no longer supported
-        * @return string
-        */
-       public function getVersion() {
-               wfDeprecated( __METHOD__, '1.21' );
-               return '';
-       }
-
        /**
         * Formerly used to fetch a list of possible properites in the result,
         * somehow organized with respect to the prop parameter that causes them to
index ca9ceca..196c1fa 100644 (file)
@@ -184,11 +184,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data['git-hash'] = $git;
                        $data['git-branch'] =
                                SpecialVersion::getGitCurrentBranch( $GLOBALS['IP'] );
-               } else {
-                       $svn = SpecialVersion::getSvnRevision( $IP );
-                       if ( $svn ) {
-                               $data['rev'] = $svn;
-                       }
                }
 
                // 'case-insensitive' option is reserved for future
@@ -602,11 +597,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                }
                                if ( isset( $ext['version'] ) ) {
                                        $ret['version'] = $ext['version'];
-                               } elseif ( isset( $ext['svn-revision'] ) &&
-                                       preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
-                                               $ext['svn-revision'], $m )
-                               ) {
-                                       $ret['version'] = 'r' . $m[1];
                                }
                                if ( isset( $ext['path'] ) ) {
                                        $extensionPath = dirname( $ext['path'] );
@@ -620,13 +610,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                                if ( $vcsDate !== false ) {
                                                        $ret['vcs-date'] = wfTimestamp( TS_ISO_8601, $vcsDate );
                                                }
-                                       } else {
-                                               $svnInfo = SpecialVersion::getSvnInfo( $extensionPath );
-                                               if ( $svnInfo !== false ) {
-                                                       $ret['vcs-system'] = 'svn';
-                                                       $ret['vcs-version'] = $svnInfo['checkout-rev'];
-                                                       $ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
-                                               }
                                        }
 
                                        if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
index b029a1d..7199389 100644 (file)
@@ -1391,6 +1391,9 @@ class LoadBalancer {
                }
 
                $pos = $pos ?: $this->getConnection( DB_MASTER )->getMasterPos();
+               if ( !$pos ) {
+                       return false; // something is misconfigured
+               }
 
                $result = $conn->masterPosWait( $pos, $timeout );
                if ( $result == -1 || is_null( $result ) ) {
index e2d9946..b99cb41 100644 (file)
@@ -67,7 +67,7 @@ class LogFormatter {
        /**
         * Handy shortcut for constructing a formatter directly from
         * database row.
-        * @param object $row
+        * @param stdClass|array $row
         * @see DatabaseLogEntry::getSelectQueryData
         * @return LogFormatter
         */
@@ -237,7 +237,7 @@ class LogFormatter {
                                        // @codingStandardsIgnoreStart Long line
                                        //case 'revision': // Revision deletion
                                        //case 'event': // Log deletion
-                                       // see https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/LogPage.php?&pathrev=97044&r1=97043&r2=97044
+                                       // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395
                                        //default:
                                        // @codingStandardsIgnoreEnd
                                }
@@ -245,7 +245,7 @@ class LogFormatter {
 
                        case 'patrol':
                                // @codingStandardsIgnoreStart Long line
-                               // https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/PatrolLog.php?&pathrev=97495&r1=97494&r2=97495
+                               // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff
                                // @codingStandardsIgnoreEnd
                                // Create a diff link to the patrolled revision
                                if ( $entry->getSubtype() === 'patrol' ) {
index e51b434..8bac6b8 100644 (file)
@@ -166,22 +166,21 @@ class EmailNotification {
                        }
                }
 
-               if ( !$sendEmail ) {
-                       return;
+               if ( $sendEmail ) {
+                       JobQueueGroup::singleton()->lazyPush( new EnotifNotifyJob(
+                               $title,
+                               array(
+                                       'editor' => $editor->getName(),
+                                       'editorID' => $editor->getID(),
+                                       'timestamp' => $timestamp,
+                                       'summary' => $summary,
+                                       'minorEdit' => $minorEdit,
+                                       'oldid' => $oldid,
+                                       'watchers' => $watchers,
+                                       'pageStatus' => $pageStatus
+                               )
+                       ) );
                }
-
-               $params = array(
-                       'editor' => $editor->getName(),
-                       'editorID' => $editor->getID(),
-                       'timestamp' => $timestamp,
-                       'summary' => $summary,
-                       'minorEdit' => $minorEdit,
-                       'oldid' => $oldid,
-                       'watchers' => $watchers,
-                       'pageStatus' => $pageStatus
-               );
-               $job = new EnotifNotifyJob( $title, $params );
-               JobQueueGroup::singleton()->lazyPush( $job );
        }
 
        /**
index f86daaa..2a13ed2 100644 (file)
@@ -65,7 +65,9 @@ final class SessionBackend {
        private $dataHash = null;
 
        /** @var BagOStuff */
-       private $store;
+       private $tempStore;
+       /** @var BagOStuff */
+       private $permStore;
 
        /** @var LoggerInterface */
        private $logger;
@@ -97,12 +99,14 @@ final class SessionBackend {
        /**
         * @param SessionId $id Session ID object
         * @param SessionInfo $info Session info to populate from
-        * @param BagOStuff $store Backend data store
+        * @param BagOStuff $tempStore In-process data store
+        * @param BagOStuff $permstore Backend data store for persisted sessions
         * @param LoggerInterface $logger
         * @param int $lifetime Session data lifetime in seconds
         */
        public function __construct(
-               SessionId $id, SessionInfo $info, BagOStuff $store, LoggerInterface $logger, $lifetime
+               SessionId $id, SessionInfo $info, BagOStuff $tempStore, BagOStuff $permStore,
+               LoggerInterface $logger, $lifetime
        ) {
                $phpSessionHandling = \RequestContext::getMain()->getConfig()->get( 'PHPSessionHandling' );
                $this->usePhpSessionHandling = $phpSessionHandling !== 'disable';
@@ -121,7 +125,8 @@ final class SessionBackend {
 
                $this->id = $id;
                $this->user = $info->getUserInfo() ? $info->getUserInfo()->getUser() : new User;
-               $this->store = $store;
+               $this->tempStore = $tempStore;
+               $this->permStore = $permStore;
                $this->logger = $logger;
                $this->lifetime = $lifetime;
                $this->provider = $info->getProvider();
@@ -130,7 +135,14 @@ final class SessionBackend {
                $this->forceHTTPS = $info->forceHTTPS();
                $this->providerMetadata = $info->getProviderMetadata();
 
-               $blob = $store->get( wfMemcKey( 'MWSession', (string)$this->id ) );
+               $key = wfMemcKey( 'MWSession', (string)$this->id );
+               $blob = $tempStore->get( $key );
+               if ( $blob === false ) {
+                       $blob = $permStore->get( $key );
+                       if ( $blob !== false ) {
+                               $tempStore->set( $key, $blob );
+                       }
+               }
                if ( !is_array( $blob ) ||
                        !isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) ||
                        !isset( $blob['data'] ) || !is_array( $blob['data'] )
@@ -229,7 +241,8 @@ final class SessionBackend {
                        $this->autosave();
 
                        // Delete the data for the old session ID now
-                       $this->store->delete( wfMemcKey( 'MWSession', $oldId ) );
+                       $this->tempStore->delete( wfMemcKey( 'MWSession', $oldId ) );
+                       $this->permStore->delete( wfMemcKey( 'MWSession', $oldId ) );
                }
        }
 
@@ -613,7 +626,7 @@ final class SessionBackend {
                        }
                }
 
-               $this->store->set(
+               $this->tempStore->set(
                        wfMemcKey( 'MWSession', (string)$this->id ),
                        array(
                                'data' => $this->data,
@@ -621,6 +634,16 @@ final class SessionBackend {
                        ),
                        $metadata['expires']
                );
+               if ( $this->persist ) {
+                       $this->permStore->set(
+                               wfMemcKey( 'MWSession', (string)$this->id ),
+                               array(
+                                       'data' => $this->data,
+                                       'metadata' => $metadata,
+                               ),
+                               $metadata['expires']
+                       );
+               }
 
                $this->metaDirty = false;
                $this->dataDirty = false;
index 06a765c..6b221fd 100644 (file)
@@ -55,7 +55,10 @@ final class SessionManager implements SessionManagerInterface {
        private $config;
 
        /** @var BagOStuff|null */
-       private $store;
+       private $tempStore;
+
+       /** @var BagOStuff|null */
+       private $permStore;
 
        /** @var SessionProvider[] */
        private $sessionProviders = null;
@@ -159,16 +162,17 @@ final class SessionManager implements SessionManagerInterface {
                        $this->setLogger( \MediaWiki\Logger\LoggerFactory::getInstance( 'session' ) );
                }
 
+               $this->tempStore = new \HashBagOStuff;
                if ( isset( $options['store'] ) ) {
                        if ( !$options['store'] instanceof BagOStuff ) {
                                throw new \InvalidArgumentException(
                                        '$options[\'store\'] must be an instance of BagOStuff'
                                );
                        }
-                       $this->store = $options['store'];
+                       $this->permStore = $options['store'];
                } else {
-                       $this->store = \ObjectCache::getInstance( $this->config->get( 'SessionCacheType' ) );
-                       $this->store->setLogger( $this->logger );
+                       $this->permStore = \ObjectCache::getInstance( $this->config->get( 'SessionCacheType' ) );
+                       $this->permStore->setLogger( $this->logger );
                }
 
                register_shutdown_function( array( $this, 'shutdown' ) );
@@ -202,7 +206,14 @@ final class SessionManager implements SessionManagerInterface {
                // Test this here to provide a better log message for the common case
                // of "no such ID"
                $key = wfMemcKey( 'MWSession', $id );
-               if ( is_array( $this->store->get( $key ) ) ) {
+               $existing = $this->tempStore->get( $key );
+               if ( $existing === false ) {
+                       $existing = $this->permStore->get( $key );
+                       if ( $existing !== false ) {
+                               $this->tempStore->set( $key, $existing );
+                       }
+               }
+               if ( is_array( $existing ) ) {
                        $info = new SessionInfo( SessionInfo::MIN_PRIORITY, array( 'id' => $id, 'idIsSafe' => true ) );
                        if ( $this->loadSessionInfoFromStore( $info, $request ) ) {
                                $session = $this->getSessionFromInfo( $info, $request );
@@ -240,7 +251,14 @@ final class SessionManager implements SessionManagerInterface {
                        }
 
                        $key = wfMemcKey( 'MWSession', $id );
-                       if ( is_array( $this->store->get( $key ) ) ) {
+                       $existing = $this->tempStore->get( $key );
+                       if ( $existing === false ) {
+                               $existing = $this->permStore->get( $key );
+                               if ( $existing !== false ) {
+                                       $this->tempStore->set( $key, $existing );
+                               }
+                       }
+                       if ( is_array( $existing ) ) {
                                throw new \InvalidArgumentException( 'Session ID already exists' );
                        }
                }
@@ -521,7 +539,7 @@ final class SessionManager implements SessionManagerInterface {
                // Reset the user's token to kill existing sessions
                $user = User::newFromName( $username );
                if ( $user && $user->getToken( false ) ) {
-                       $user->setToken( true );
+                       $user->setToken();
                        $user->saveSettings();
                }
 
@@ -660,7 +678,13 @@ final class SessionManager implements SessionManagerInterface {
         */
        private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
                $key = wfMemcKey( 'MWSession', $info->getId() );
-               $blob = $this->store->get( $key );
+               $blob = $this->tempStore->get( $key );
+               if ( $blob === false ) {
+                       $blob = $this->permStore->get( $key );
+                       if ( $blob !== false ) {
+                               $this->tempStore->set( $key, $blob );
+                       }
+               }
 
                $newParams = array();
 
@@ -668,7 +692,8 @@ final class SessionManager implements SessionManagerInterface {
                        // Sanity check: blob must be an array, if it's saved at all
                        if ( !is_array( $blob ) ) {
                                $this->logger->warning( "Session $info: Bad data" );
-                               $this->store->delete( $key );
+                               $this->tempStore->delete( $key );
+                               $this->permStore->delete( $key );
                                return false;
                        }
 
@@ -677,7 +702,8 @@ final class SessionManager implements SessionManagerInterface {
                                !isset( $blob['metadata'] ) || !is_array( $blob['metadata'] )
                        ) {
                                $this->logger->warning( "Session $info: Bad data structure" );
-                               $this->store->delete( $key );
+                               $this->tempStore->delete( $key );
+                               $this->permStore->delete( $key );
                                return false;
                        }
 
@@ -692,7 +718,8 @@ final class SessionManager implements SessionManagerInterface {
                                !array_key_exists( 'provider', $metadata )
                        ) {
                                $this->logger->warning( "Session $info: Bad metadata" );
-                               $this->store->delete( $key );
+                               $this->tempStore->delete( $key );
+                               $this->permStore->delete( $key );
                                return false;
                        }
 
@@ -702,7 +729,8 @@ final class SessionManager implements SessionManagerInterface {
                                $newParams['provider'] = $provider = $this->getProvider( $metadata['provider'] );
                                if ( !$provider ) {
                                        $this->logger->warning( "Session $info: Unknown provider, " . $metadata['provider'] );
-                                       $this->store->delete( $key );
+                                       $this->tempStore->delete( $key );
+                                       $this->permStore->delete( $key );
                                        return false;
                                }
                        } elseif ( $metadata['provider'] !== (string)$provider ) {
@@ -893,7 +921,8 @@ final class SessionManager implements SessionManagerInterface {
                        $backend = new SessionBackend(
                                $this->allSessionIds[$id],
                                $info,
-                               $this->store,
+                               $this->tempStore,
+                               $this->permStore,
                                $this->logger,
                                $this->config->get( 'ObjectCacheSessionExpiry' )
                        );
@@ -970,7 +999,9 @@ final class SessionManager implements SessionManagerInterface {
                do {
                        $id = wfBaseConvert( \MWCryptRand::generateHex( 40 ), 16, 32, 32 );
                        $key = wfMemcKey( 'MWSession', $id );
-               } while ( isset( $this->allSessionIds[$id] ) || is_array( $this->store->get( $key ) ) );
+               } while ( isset( $this->allSessionIds[$id] ) ||
+                       is_array( $this->tempStore->get( $key ) ) || is_array( $this->permStore->get( $key ) )
+               );
                return $id;
        }
 
@@ -980,7 +1011,7 @@ final class SessionManager implements SessionManagerInterface {
         * @param PHPSessionHandler $handler
         */
        public function setupPHPSessionHandler( PHPSessionHandler $handler ) {
-               $handler->setManager( $this, $this->store, $this->logger );
+               $handler->setManager( $this, $this->permStore, $this->logger );
        }
 
        /**
index 43228fa..a628902 100644 (file)
@@ -38,12 +38,6 @@ class SpecialVersion extends SpecialPage {
 
        protected static $extensionTypes = false;
 
-       protected static $viewvcUrls = array(
-               'svn+ssh://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
-               'http://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
-               'https://svn.wikimedia.org/svnroot/mediawiki' => 'https://svn.wikimedia.org/viewvc/mediawiki',
-       );
-
        public function __construct() {
                parent::__construct( 'Version' );
        }
@@ -258,7 +252,7 @@ class SpecialVersion extends SpecialPage {
        }
 
        /**
-        * Return a string of the MediaWiki version with SVN revision if available.
+        * Return a string of the MediaWiki version with Git revision if available.
         *
         * @param string $flags
         * @return mixed
@@ -267,25 +261,15 @@ class SpecialVersion extends SpecialPage {
                global $wgVersion, $IP;
 
                $gitInfo = self::getGitHeadSha1( $IP );
-               $svnInfo = self::getSvnInfo( $IP );
-               if ( !$svnInfo && !$gitInfo ) {
+               if ( !$gitInfo ) {
                        $version = $wgVersion;
-               } elseif ( $gitInfo && $flags === 'nodb' ) {
+               } elseif ( $flags === 'nodb' ) {
                        $shortSha1 = substr( $gitInfo, 0, 7 );
                        $version = "$wgVersion ($shortSha1)";
-               } elseif ( $gitInfo ) {
+               } else {
                        $shortSha1 = substr( $gitInfo, 0, 7 );
                        $shortSha1 = wfMessage( 'parentheses' )->params( $shortSha1 )->escaped();
                        $version = "$wgVersion $shortSha1";
-               } elseif ( $flags === 'nodb' ) {
-                       $version = "$wgVersion (r{$svnInfo['checkout-rev']})";
-               } else {
-                       $version = $wgVersion . ' ' .
-                               wfMessage(
-                                       'version-svn-revision',
-                                       isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : '',
-                                       isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : ''
-                               )->text();
                }
 
                return $version;
@@ -293,8 +277,7 @@ class SpecialVersion extends SpecialPage {
 
        /**
         * Return a wikitext-formatted string of the MediaWiki version with a link to
-        * the SVN revision or the git SHA1 of head if available.
-        * Git is prefered over Svn
+        * the Git SHA1 of head if available.
         * The fallback is just $wgVersion
         *
         * @return mixed
@@ -306,43 +289,12 @@ class SpecialVersion extends SpecialPage {
                if ( $gitVersion ) {
                        $v = $gitVersion;
                } else {
-                       $svnVersion = self::getVersionLinkedSvn();
-                       if ( $svnVersion ) {
-                               $v = $svnVersion;
-                       } else {
-                               $v = $wgVersion; // fallback
-                       }
+                       $v = $wgVersion; // fallback
                }
 
                return $v;
        }
 
-       /**
-        * @return string Global wgVersion + a link to subversion revision of svn BASE
-        */
-       private static function getVersionLinkedSvn() {
-               global $IP;
-
-               $info = self::getSvnInfo( $IP );
-               if ( !isset( $info['checkout-rev'] ) ) {
-                       return false;
-               }
-
-               $linkText = wfMessage(
-                       'version-svn-revision',
-                       isset( $info['directory-rev'] ) ? $info['directory-rev'] : '',
-                       $info['checkout-rev']
-               )->text();
-
-               if ( isset( $info['viewvc-url'] ) ) {
-                       $version = "[{$info['viewvc-url']} $linkText]";
-               } else {
-                       $version = $linkText;
-               }
-
-               return self::getwgVersionLinked() . " $version";
-       }
-
        /**
         * @return string
         */
@@ -744,7 +696,7 @@ class SpecialVersion extends SpecialPage {
                }
 
                // ... and the version information
-               // If the extension path is set we will check that directory for GIT and SVN
+               // If the extension path is set we will check that directory for GIT
                // metadata in an attempt to extract date and vcs commit metadata.
                $canonicalVersion = '&ndash;';
                $extensionPath = null;
@@ -764,11 +716,6 @@ class SpecialVersion extends SpecialPage {
                                $coreHeadSHA1 = self::getGitHeadSha1( $IP );
                                if ( $coreHeadSHA1 ) {
                                        $this->coreId = $coreHeadSHA1;
-                               } else {
-                                       $svnInfo = self::getSvnInfo( $IP );
-                                       if ( $svnInfo !== false ) {
-                                               $this->coreId = $svnInfo['checkout-rev'];
-                                       }
                                }
                        }
                        $cache = wfGetCache( CACHE_ANYTHING );
@@ -783,12 +730,6 @@ class SpecialVersion extends SpecialPage {
                                        $vcsVersion = substr( $vcsVersion, 0, 7 );
                                        $vcsLink = $gitInfo->getHeadViewUrl();
                                        $vcsDate = $gitInfo->getHeadCommitDate();
-                               } else {
-                                       $svnInfo = self::getSvnInfo( $extensionPath );
-                                       if ( $svnInfo !== false ) {
-                                               $vcsVersion = $this->msg( 'version-svn-revision', $svnInfo['checkout-rev'] )->text();
-                                               $vcsLink = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
-                                       }
                                }
                                $cache->set( $memcKey, array( $vcsVersion, $vcsLink, $vcsDate ), 60 * 60 * 24 );
                        } else {
@@ -1154,108 +1095,6 @@ class SpecialVersion extends SpecialPage {
                }
        }
 
-       /**
-        * Get an associative array of information about a given path, from its .svn
-        * subdirectory. Returns false on error, such as if the directory was not
-        * checked out with subversion.
-        *
-        * Returned keys are:
-        *    Required:
-        *        checkout-rev          The revision which was checked out
-        *    Optional:
-        *        directory-rev         The revision when the directory was last modified
-        *        url                   The subversion URL of the directory
-        *        repo-url              The base URL of the repository
-        *        viewvc-url            A ViewVC URL pointing to the checked-out revision
-        * @param string $dir
-        * @return array|bool
-        */
-       public static function getSvnInfo( $dir ) {
-               // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
-               $entries = $dir . '/.svn/entries';
-
-               if ( !file_exists( $entries ) ) {
-                       return false;
-               }
-
-               $lines = file( $entries );
-               if ( !count( $lines ) ) {
-                       return false;
-               }
-
-               // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4)
-               if ( preg_match( '/^<\?xml/', $lines[0] ) ) {
-                       // subversion is release <= 1.3
-                       if ( !function_exists( 'simplexml_load_file' ) ) {
-                               // We could fall back to expat... YUCK
-                               return false;
-                       }
-
-                       // SimpleXml whines about the xmlns...
-                       MediaWiki\suppressWarnings();
-                       $xml = simplexml_load_file( $entries );
-                       MediaWiki\restoreWarnings();
-
-                       if ( $xml ) {
-                               foreach ( $xml->entry as $entry ) {
-                                       if ( $xml->entry[0]['name'] == '' ) {
-                                               // The directory entry should always have a revision marker.
-                                               if ( $entry['revision'] ) {
-                                                       return array( 'checkout-rev' => intval( $entry['revision'] ) );
-                                               }
-                                       }
-                               }
-                       }
-
-                       return false;
-               }
-
-               // Subversion is release 1.4 or above.
-               if ( count( $lines ) < 11 ) {
-                       return false;
-               }
-
-               $info = array(
-                       'checkout-rev' => intval( trim( $lines[3] ) ),
-                       'url' => trim( $lines[4] ),
-                       'repo-url' => trim( $lines[5] ),
-                       'directory-rev' => intval( trim( $lines[10] ) )
-               );
-
-               if ( isset( self::$viewvcUrls[$info['repo-url']] ) ) {
-                       $viewvc = str_replace(
-                               $info['repo-url'],
-                               self::$viewvcUrls[$info['repo-url']],
-                               $info['url']
-                       );
-
-                       $viewvc .= '/?pathrev=';
-                       $viewvc .= urlencode( $info['checkout-rev'] );
-                       $info['viewvc-url'] = $viewvc;
-               }
-
-               return $info;
-       }
-
-       /**
-        * Retrieve the revision number of a Subversion working directory.
-        *
-        * @param string $dir Directory of the svn checkout
-        *
-        * @return int Revision number
-        */
-       public static function getSvnRevision( $dir ) {
-               $info = self::getSvnInfo( $dir );
-
-               if ( $info === false ) {
-                       return false;
-               } elseif ( isset( $info['checkout-rev'] ) ) {
-                       return $info['checkout-rev'];
-               } else {
-                       return false;
-               }
-       }
-
        /**
         * @param string $dir Directory of the git checkout
         * @return bool|string Sha1 of commit HEAD points to
index 639af0f..bf906d5 100644 (file)
        "version-hook-subscribedby": "Subscribed by",
        "version-version": "($1)",
        "version-no-ext-name": "[no name]",
-       "version-svn-revision": "r$1",
        "version-license": "MediaWiki License",
        "version-ext-license": "License",
        "version-ext-colheader-name": "Extension",
index 61aaeaa..d66e43e 100644 (file)
        "version-hook-subscribedby": "Shown in [[Special:Version]]",
        "version-version": "{{Optional}}\nUsed in [[Special:Version]]. Preceded by the MediaWiki extension name.\n\nParameters:\n* $1 - version number of the extension",
        "version-no-ext-name": "Used in [[Special:Version]], in the rows of the main table when a name for an extension is not provided.",
-       "version-svn-revision": "{{Identical|Revision}}{{optional}}\nUsed in [[Special:Version]], preceeding the Subversion revision numbers of the extensions loaded inside brackets, like this: \"({{int:version-revision}} r012345\"). Parameters:\n* $1 - (Unused) directory revision number or empty string\n* $2 - checkout revision number",
        "version-license": "Used specifically for the MediaWiki software.\n\nUsed as heading in [[Special:Version]].",
        "version-ext-license": "Used in [[Special:Version]].\n\nUsed as label for the link pointing to the extension's license page. e.g. [[Special:Version/License/Maps]]\n{{Identical|License}}",
        "version-ext-colheader-name": "Column header for the name of an extension.\n{{Identical|Extension}}",
index 702f556..2b7e0a1 100644 (file)
@@ -363,6 +363,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase {
                                'idIsSafe' => true,
                        ) ),
                        $store,
+                       $store,
                        new \Psr\Log\NullLogger(),
                        10
                );
@@ -449,6 +450,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase {
                                'idIsSafe' => true,
                        ) ),
                        new \EmptyBagOStuff(),
+                       new \EmptyBagOStuff(),
                        new \Psr\Log\NullLogger(),
                        10
                );
@@ -553,6 +555,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase {
                                'idIsSafe' => true,
                        ) ),
                        $store,
+                       $store,
                        new \Psr\Log\NullLogger(),
                        10
                );
index e06dfd5..46f23f3 100644 (file)
@@ -205,6 +205,7 @@ class ImmutableSessionProviderWithCookieTest extends MediaWikiTestCase {
                                'idIsSafe' => true,
                        ) ),
                        new \EmptyBagOStuff(),
+                       new \EmptyBagOStuff(),
                        new \Psr\Log\NullLogger(),
                        10
                );
index 125e1b6..1c54a20 100644 (file)
@@ -172,14 +172,6 @@ class PHPSessionHandlerTest extends MediaWikiTestCase {
                        $this->assertSame( $expect, $_SESSION );
                }
 
-               // Test expiry
-               session_write_close();
-               ini_set( 'session.gc_divisor', 1 );
-               ini_set( 'session.gc_probability', 1 );
-               sleep( 3 );
-               session_start();
-               $this->assertSame( array(), $_SESSION );
-
                // Re-fill the session, then test that session_destroy() works.
                $_SESSION['AuthenticationSessionTest'] = $rand;
                session_write_close();
index d06706b..85fa9bd 100644 (file)
@@ -59,7 +59,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                ) );
                $id = new SessionId( $info->getId() );
 
-               $backend = new SessionBackend( $id, $info, $this->store, $logger, 10 );
+               $backend = new SessionBackend( $id, $info, $this->store, $this->store, $logger, 10 );
                $priv = \TestingAccessWrapper::newFromObject( $backend );
                $priv->persist = false;
                $priv->requests = array( 100 => new \FauxRequest() );
@@ -87,7 +87,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                $id = new SessionId( $info->getId() );
                $logger = new \Psr\Log\NullLogger();
                try {
-                       new SessionBackend( $id, $info, $this->store, $logger, 10 );
+                       new SessionBackend( $id, $info, $this->store, $this->store, $logger, 10 );
                        $this->fail( 'Expected exception not thrown' );
                } catch ( \InvalidArgumentException $ex ) {
                        $this->assertSame(
@@ -103,7 +103,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                ) );
                $id = new SessionId( $info->getId() );
                try {
-                       new SessionBackend( $id, $info, $this->store, $logger, 10 );
+                       new SessionBackend( $id, $info, $this->store, $this->store, $logger, 10 );
                        $this->fail( 'Expected exception not thrown' );
                } catch ( \InvalidArgumentException $ex ) {
                        $this->assertSame( 'Cannot create session without a provider', $ex->getMessage() );
@@ -118,7 +118,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                ) );
                $id = new SessionId( '!' . $info->getId() );
                try {
-                       new SessionBackend( $id, $info, $this->store, $logger, 10 );
+                       new SessionBackend( $id, $info, $this->store, $this->store, $logger, 10 );
                        $this->fail( 'Expected exception not thrown' );
                } catch ( \InvalidArgumentException $ex ) {
                        $this->assertSame(
@@ -135,7 +135,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                        'idIsSafe' => true,
                ) );
                $id = new SessionId( $info->getId() );
-               $backend = new SessionBackend( $id, $info, $this->store, $logger, 10 );
+               $backend = new SessionBackend( $id, $info, $this->store, $this->store, $logger, 10 );
                $this->assertSame( self::SESSIONID, $backend->getId() );
                $this->assertSame( $id, $backend->getSessionId() );
                $this->assertSame( $this->provider, $backend->getProvider() );
@@ -157,7 +157,7 @@ class SessionBackendTest extends MediaWikiTestCase {
                        'idIsSafe' => true,
                ) );
                $id = new SessionId( $info->getId() );
-               $backend = new SessionBackend( $id, $info, $this->store, $logger, 10 );
+               $backend = new SessionBackend( $id, $info, $this->store, $this->store, $logger, 10 );
                $this->assertSame( self::SESSIONID, $backend->getId() );
                $this->assertSame( $id, $backend->getSessionId() );
                $this->assertSame( $this->provider, $backend->getProvider() );
index f5bb07d..4fde341 100644 (file)
@@ -103,7 +103,7 @@ class SessionManagerTest extends MediaWikiTestCase {
                $manager = \TestingAccessWrapper::newFromObject( $this->getManager() );
                $this->assertSame( $this->config, $manager->config );
                $this->assertSame( $this->logger, $manager->logger );
-               $this->assertSame( $this->store, $manager->store );
+               $this->assertSame( $this->store, $manager->permStore );
 
                $manager = \TestingAccessWrapper::newFromObject( new SessionManager() );
                $this->assertSame( \RequestContext::getMain()->getConfig(), $manager->config );
@@ -111,7 +111,7 @@ class SessionManagerTest extends MediaWikiTestCase {
                $manager = \TestingAccessWrapper::newFromObject( new SessionManager( array(
                        'config' => $this->config,
                ) ) );
-               $this->assertSame( \ObjectCache::$instances['testSessionStore'], $manager->store );
+               $this->assertSame( \ObjectCache::$instances['testSessionStore'], $manager->permStore );
 
                foreach ( array(
                        'config' => '$options[\'config\'] must be an instance of Config',
@@ -301,6 +301,9 @@ class SessionManagerTest extends MediaWikiTestCase {
        public function testGetSessionById() {
                $manager = $this->getManager();
 
+               // Disable the in-process cache so our $this->store->setSession() takes effect.
+               \TestingAccessWrapper::newFromObject( $manager )->tempStore = new \EmptyBagOStuff;
+
                try {
                        $manager->getSessionById( 'bad' );
                        $this->fail( 'Expected exception not thrown' );
@@ -1083,6 +1086,9 @@ class SessionManagerTest extends MediaWikiTestCase {
                $manager->setLogger( $logger );
                $request = new \FauxRequest();
 
+               // Disable the in-process cache so our $this->store->setSession() takes effect.
+               \TestingAccessWrapper::newFromObject( $manager )->tempStore = new \EmptyBagOStuff;
+
                // TestingAccessWrapper can't handle methods with reference arguments, sigh.
                $rClass = new \ReflectionClass( $manager );
                $rMethod = $rClass->getMethod( 'loadSessionInfoFromStore' );