Merge "Warn if stateful ParserOutput transforms are used"
[lhc/web/wiklou.git] / includes / Storage / RevisionStore.php
index b6a751b..79ecec6 100644 (file)
@@ -1484,13 +1484,29 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
         * @throws MWException
         */
        private function checkDatabaseWikiId( IDatabase $db ) {
-               $storeWiki = $this->loadBalancer->getLocalDomainID();
+               $storeWiki = $this->wikiId;
                $dbWiki = $db->getDomainID();
 
                if ( $dbWiki === $storeWiki ) {
                        return;
                }
 
+               // XXX: we really want the default database ID...
+               $storeWiki = $storeWiki ?: wfWikiID();
+               $dbWiki = $dbWiki ?: wfWikiID();
+
+               if ( $dbWiki === $storeWiki ) {
+                       return;
+               }
+
+               // HACK: counteract encoding imposed by DatabaseDomain
+               $storeWiki = str_replace( '?h', '-', $storeWiki );
+               $dbWiki = str_replace( '?h', '-', $dbWiki );
+
+               if ( $dbWiki === $storeWiki ) {
+                       return;
+               }
+
                throw new MWException( "RevisionStore for $storeWiki "
                        . "cannot be used with a DB connection for $dbWiki" );
        }