Merge "mw.Feedback: If the message is posted remotely, link the title correctly"
[lhc/web/wiklou.git] / includes / Storage / RevisionStore.php
index b0c193b..b6a751b 100644 (file)
@@ -190,7 +190,7 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
 
                // rev_id is defined as NOT NULL, but this revision may not yet have been inserted.
                if ( !$title && $revId !== null && $revId > 0 ) {
-                       $dbr = $this->getDbConnectionRef( $dbMode );
+                       $dbr = $this->getDBConnectionRef( $dbMode );
                        // @todo: Title::getSelectFields(), or Title::getQueryInfo(), or something like that
                        $row = $dbr->selectRow(
                                [ 'revision', 'page' ],
@@ -804,7 +804,8 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
         * @param SlotRecord $slot The SlotRecord to load content for
         * @param string|null $blobData The content blob, in the form indicated by $blobFlags
         * @param string|null $blobFlags Flags indicating how $blobData needs to be processed.
-        *  null if no processing should happen.
+        *        Use null if no processing should happen. That is in constrast to the empty string,
+        *        which causes the blob to be decoded according to the configured legacy encoding.
         * @param string|null $blobFormat MIME type indicating how $dataBlob is encoded
         * @param int $queryFlags
         *
@@ -825,6 +826,7 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
                        $cacheKey = $slot->hasAddress() ? $slot->getAddress() : null;
 
                        if ( $blobFlags === null ) {
+                               // No blob flags, so use the blob verbatim.
                                $data = $blobData;
                        } else {
                                $data = $this->blobStore->expandBlob( $blobData, $blobFlags, $cacheKey );
@@ -1482,29 +1484,13 @@ class RevisionStore implements IDBAccessObject, RevisionFactory, RevisionLookup
         * @throws MWException
         */
        private function checkDatabaseWikiId( IDatabase $db ) {
-               $storeWiki = $this->wikiId;
+               $storeWiki = $this->loadBalancer->getLocalDomainID();
                $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" );
        }