Merge "Handle failure to load content in Revision getSize, etc"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 11 Jan 2018 14:50:00 +0000 (14:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 11 Jan 2018 14:50:00 +0000 (14:50 +0000)
1  2 
includes/Revision.php

diff --combined includes/Revision.php
@@@ -608,20 -608,27 +608,27 @@@ class Revision implements IDBAccessObje
        /**
         * Returns the length of the text in this revision, or null if unknown.
         *
-        * @return int
+        * @return int|null
         */
        public function getSize() {
-               return $this->mRecord->getSize();
+               try {
+                       return $this->mRecord->getSize();
+               } catch ( RevisionAccessException $ex ) {
+                       return null;
+               }
        }
  
        /**
         * Returns the base36 sha1 of the content in this revision, or null if unknown.
         *
-        * @return string
+        * @return string|null
         */
        public function getSha1() {
-               // XXX: we may want to drop all the hashing logic, it's not worth the overhead.
-               return $this->mRecord->getSha1();
+               try {
+                       return $this->mRecord->getSha1();
+               } catch ( RevisionAccessException $ex ) {
+                       return null;
+               }
        }
  
        /**
  
                $comment = CommentStoreComment::newUnsavedComment( $summary, null );
  
 -              $title = Title::newFromID( $pageId );
 +              $title = Title::newFromID( $pageId, Title::GAID_FOR_UPDATE );
 +              if ( $title === null ) {
 +                      return null;
 +              }
 +
                $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
  
                return new Revision( $rec );