Merge "mw.Upload.BookletLayout: Don't explode when the API call fails with 'exception'"
[lhc/web/wiklou.git] / includes / filerepo / file / ForeignAPIFile.php
index cad806d..43cb5a5 100644 (file)
@@ -218,6 +218,25 @@ class ForeignAPIFile extends File {
                return isset( $this->mInfo['url'] ) ? strval( $this->mInfo['url'] ) : null;
        }
 
+       /**
+        * Get short description URL for a file based on the foreign API response,
+        * or if unavailable, the short URL is constructed from the foreign page ID.
+        *
+        * @return null|string
+        * @since 1.27
+        */
+       public function getDescriptionShortUrl() {
+               if ( isset( $this->mInfo['descriptionshorturl'] ) ) {
+                       return $this->mInfo['descriptionshorturl'];
+               } elseif ( isset( $this->mInfo['pageid'] ) ) {
+                       $url = $this->repo->makeUrl( array( 'curid' => $this->mInfo['pageid'] ) );
+                       if ( $url !== false ) {
+                               return $url;
+                       }
+               }
+               return null;
+       }
+
        /**
         * @param string $type
         * @return int|null|string
@@ -244,7 +263,7 @@ class ForeignAPIFile extends File {
         */
        function getSha1() {
                return isset( $this->mInfo['sha1'] )
-                       ? wfBaseConvert( strval( $this->mInfo['sha1'] ), 16, 36, 31 )
+                       ? Wikimedia\base_convert( strval( $this->mInfo['sha1'] ), 16, 36, 31 )
                        : null;
        }