Merge "Introduce ContentHandler::getSecondaryDataUpdates."
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 7206dce..fa6e180 100644 (file)
@@ -2115,17 +2115,22 @@ class LocalFile extends File {
         * @param Language|null $lang What language to get description in (Optional)
         * @return string|false
         */
-       function getDescriptionText( $lang = null ) {
-               $revision = Revision::newFromTitle( $this->title, false, Revision::READ_NORMAL );
+       function getDescriptionText( Language $lang = null ) {
+               $store = MediaWikiServices::getInstance()->getRevisionStore();
+               $revision = $store->getRevisionByTitle( $this->title, 0, Revision::READ_NORMAL );
                if ( !$revision ) {
                        return false;
                }
-               $content = $revision->getContent();
-               if ( !$content ) {
+
+               $renderer = MediaWikiServices::getInstance()->getRevisionRenderer();
+               $rendered = $renderer->getRenderedRevision( $revision, new ParserOptions( null, $lang ) );
+
+               if ( !$rendered ) {
+                       // audience check failed
                        return false;
                }
-               $pout = $content->getParserOutput( $this->title, null, new ParserOptions( null, $lang ) );
 
+               $pout = $rendered->getRevisionParserOutput();
                return $pout->getText();
        }
 
@@ -3146,7 +3151,7 @@ class LocalFileRestoreBatch {
 
        /**
         * Cleanup a failed batch. The batch was only partially successful, so
-        * rollback by removing all items that were succesfully copied.
+        * rollback by removing all items that were successfully copied.
         *
         * @param Status $storeStatus
         * @param array[] $storeBatch
@@ -3344,19 +3349,15 @@ class LocalFileMoveBatch {
                $status = $repo->newGood();
                $dbw = $this->db;
 
-               $hasCurrent = $dbw->selectField(
+               $hasCurrent = $dbw->lockForUpdate(
                        'image',
-                       '1',
                        [ 'img_name' => $this->oldName ],
-                       __METHOD__,
-                       [ 'FOR UPDATE' ]
+                       __METHOD__
                );
-               $oldRowCount = $dbw->selectRowCount(
+               $oldRowCount = $dbw->lockForUpdate(
                        'oldimage',
-                       '*',
                        [ 'oi_name' => $this->oldName ],
-                       __METHOD__,
-                       [ 'FOR UPDATE' ]
+                       __METHOD__
                );
 
                if ( $hasCurrent ) {