Revision::getText() was removed
[lhc/web/wiklou.git] / includes / MediaWikiServices.php
index ff292cf..7c9363c 100644 (file)
@@ -3,6 +3,8 @@ namespace MediaWiki;
 
 use Config;
 use ConfigFactory;
+use CryptHKDF;
+use CryptRand;
 use EventRelayerGroup;
 use GenderCache;
 use GlobalVarConfig;
@@ -11,12 +13,17 @@ use LBFactory;
 use LinkCache;
 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
 use LoadBalancer;
+use MediaHandlerFactory;
 use MediaWiki\Linker\LinkRenderer;
 use MediaWiki\Linker\LinkRendererFactory;
 use MediaWiki\Services\SalvageableService;
 use MediaWiki\Services\ServiceContainer;
+use MediaWiki\Services\NoSuchServiceException;
 use MWException;
+use MimeAnalyzer;
 use ObjectCache;
+use Parser;
+use ProxyLookup;
 use SearchEngine;
 use SearchEngineConfig;
 use SearchEngineFactory;
@@ -27,6 +34,7 @@ use WatchedItemQueryService;
 use SkinFactory;
 use TitleFormatter;
 use TitleParser;
+use VirtualRESTServiceClient;
 use MediaWiki\Interwiki\InterwikiLookup;
 
 /**
@@ -176,7 +184,7 @@ class MediaWikiServices extends ServiceContainer {
 
                $oldInstance = self::$instance;
 
-               self::$instance = self::newInstance( $bootstrapConfig );
+               self::$instance = self::newInstance( $bootstrapConfig, 'load' );
                self::$instance->importWiring( $oldInstance, [ 'BootstrapConfig' ] );
 
                if ( $quick === 'quick' ) {
@@ -184,7 +192,6 @@ class MediaWikiServices extends ServiceContainer {
                } else {
                        $oldInstance->destroy();
                }
-
        }
 
        /**
@@ -196,7 +203,14 @@ class MediaWikiServices extends ServiceContainer {
         */
        private function salvage( self $other ) {
                foreach ( $this->getServiceNames() as $name ) {
-                       $oldService = $other->peekService( $name );
+                       // The service could be new in the new instance and not registered in the
+                       // other instance (e.g. an extension that was loaded after the instantiation of
+                       // the other instance. Skip this service in this case. See T143974
+                       try {
+                               $oldService = $other->peekService( $name );
+                       } catch ( NoSuchServiceException $e ) {
+                               continue;
+                       }
 
                        if ( $oldService instanceof SalvageableService ) {
                                /** @var SalvageableService $newService */
@@ -283,7 +297,7 @@ class MediaWikiServices extends ServiceContainer {
                self::resetGlobalInstance();
 
                // Child, reseed because there is no bug in PHP:
-               // http://bugs.php.net/bug.php?id=42465
+               // https://bugs.php.net/bug.php?id=42465
                mt_srand( getmypid() );
        }
 
@@ -511,6 +525,54 @@ class MediaWikiServices extends ServiceContainer {
                return $this->getService( 'WatchedItemQueryService' );
        }
 
+       /**
+        * @since 1.28
+        * @return CryptRand
+        */
+       public function getCryptRand() {
+               return $this->getService( 'CryptRand' );
+       }
+
+       /**
+        * @since 1.28
+        * @return CryptHKDF
+        */
+       public function getCryptHKDF() {
+               return $this->getService( 'CryptHKDF' );
+       }
+
+       /**
+        * @since 1.28
+        * @return MediaHandlerFactory
+        */
+       public function getMediaHandlerFactory() {
+               return $this->getService( 'MediaHandlerFactory' );
+       }
+
+       /**
+        * @since 1.28
+        * @return MimeAnalyzer
+        */
+       public function getMimeAnalyzer() {
+               return $this->getService( 'MimeAnalyzer' );
+       }
+
+       /**
+        * @since 1.28
+        * @return ProxyLookup
+        */
+       public function getProxyLookup() {
+               return $this->getService( 'ProxyLookup' );
+       }
+
+       /**
+        * @since 1.29
+        * @return Parser
+        */
+       public function getParser() {
+               return $this->getService( 'Parser' );
+       }
+
        /**
         * @since 1.28
         * @return GenderCache
@@ -562,6 +624,38 @@ class MediaWikiServices extends ServiceContainer {
                return $this->getService( 'TitleParser' );
        }
 
+       /**
+        * @since 1.28
+        * @return \BagOStuff
+        */
+       public function getMainObjectStash() {
+               return $this->getService( 'MainObjectStash' );
+       }
+
+       /**
+        * @since 1.28
+        * @return \WANObjectCache
+        */
+       public function getMainWANObjectCache() {
+               return $this->getService( 'MainWANObjectCache' );
+       }
+
+       /**
+        * @since 1.28
+        * @return \BagOStuff
+        */
+       public function getLocalServerObjectCache() {
+               return $this->getService( 'LocalServerObjectCache' );
+       }
+
+       /**
+        * @since 1.28
+        * @return VirtualRESTServiceClient
+        */
+       public function getVirtualRESTServiceClient() {
+               return $this->getService( 'VirtualRESTServiceClient' );
+       }
+
        ///////////////////////////////////////////////////////////////////////////
        // NOTE: When adding a service getter here, don't forget to add a test
        // case for it in MediaWikiServicesTest::provideGetters() and in