Merge "mw.Upload.BookletLayout: Don't explode when the API call fails with 'exception'"
[lhc/web/wiklou.git] / includes / filerepo / file / ForeignDBFile.php
index 36558c4..611ae10 100644 (file)
@@ -65,14 +65,14 @@ class ForeignDBFile extends LocalFile {
        }
 
        /**
-        * @param $oldver
-        * @param $desc string
-        * @param $license string
-        * @param $copyStatus string
-        * @param $source string
-        * @param $watch bool
-        * @param $timestamp bool|string
-        * @param $user User object or null to use $wgUser
+        * @param string $oldver
+        * @param string $desc
+        * @param string $license
+        * @param string $copyStatus
+        * @param string $source
+        * @param bool $watch
+        * @param bool|string $timestamp
+        * @param User $user User object or null to use $wgUser
         * @return bool
         * @throws MWException
         */
@@ -94,10 +94,11 @@ class ForeignDBFile extends LocalFile {
        /**
         * @param string $reason
         * @param bool $suppress
+        * @param User|null $user
         * @return FileRepoStatus
         * @throws MWException
         */
-       function delete( $reason, $suppress = false ) {
+       function delete( $reason, $suppress = false, $user = null ) {
                $this->readOnlyError();
        }
 
@@ -126,4 +127,28 @@ class ForeignDBFile extends LocalFile {
                // Restore remote behavior
                return File::getDescriptionText( $lang );
        }
+
+       /**
+        * Get short description URL for a file based on the page ID.
+        *
+        * @return string
+        * @throws DBUnexpectedError
+        * @since 1.27
+        */
+       public function getDescriptionShortUrl() {
+               $dbr = $this->repo->getSlaveDB();
+               $pageId = $dbr->selectField( 'page', 'page_id', array(
+                       'page_namespace' => NS_FILE,
+                       'page_title' => $this->title->getDBkey()
+               ) );
+
+               if ( $pageId !== false ) {
+                       $url = $this->repo->makeUrl( array( 'curid' => $pageId ) );
+                       if ( $url !== false ) {
+                               return $url;
+                       }
+               }
+               return null;
+       }
+
 }