Victorbarbu has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/262415

Change subject: [WIP]Provide short URL to file description page in imageinfo API
......................................................................

[WIP]Provide short URL to file description page in imageinfo API

Bug: T122439
Change-Id: I0f00b986e6095bdb9b8d6af6fbc5b01995227e02
---
M includes/api/ApiQueryImageInfo.php
M includes/filerepo/ForeignAPIRepo.php
M includes/filerepo/file/File.php
M includes/filerepo/file/ForeignAPIFile.php
M includes/filerepo/file/LocalFile.php
5 files changed, 36 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/15/262415/1

diff --git a/includes/api/ApiQueryImageInfo.php 
b/includes/api/ApiQueryImageInfo.php
index 8dbd812..2eb4e99 100644
--- a/includes/api/ApiQueryImageInfo.php
+++ b/includes/api/ApiQueryImageInfo.php
@@ -414,6 +414,8 @@
                        }
                }
 
+               $vals['pageid'] = $file->getPageId();
+
                // This is shown even if the file is revdelete'd in interface
                // so do same here.
                if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
diff --git a/includes/filerepo/ForeignAPIRepo.php 
b/includes/filerepo/ForeignAPIRepo.php
index debdeb5..e7955a1 100644
--- a/includes/filerepo/ForeignAPIRepo.php
+++ b/includes/filerepo/ForeignAPIRepo.php
@@ -215,10 +215,15 @@
         * @return bool|array
         */
        function getImageInfo( $data ) {
+               // TODO check this out
                if ( $data && isset( $data['query']['pages'] ) ) {
                        foreach ( $data['query']['pages'] as $info ) {
                                if ( isset( $info['imageinfo'][0] ) ) {
-                                       return $info['imageinfo'][0];
+                                       $return = $info['imageinfo'][0];
+                                       if ( isset( $info['pageid'] ) ) {
+                                               $return['curid'] = 
$info['pageid'];
+                                       }
+                                       return $return;
                                }
                        }
                }
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index 72f12d1..cf8068d 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -354,6 +354,13 @@
                return $this->url;
        }
 
+       /*
+        * Get the page id for a file
+        */
+       public function getPageId() {
+
+       }
+
        /**
         * Return a fully-qualified URL to the file.
         * Upload URL paths _may or may not_ be fully qualified, so
diff --git a/includes/filerepo/file/ForeignAPIFile.php 
b/includes/filerepo/file/ForeignAPIFile.php
index 26ea38b..20bb6da 100644
--- a/includes/filerepo/file/ForeignAPIFile.php
+++ b/includes/filerepo/file/ForeignAPIFile.php
@@ -65,6 +65,9 @@
 
                $info = $repo->getImageInfo( $data );
 
+               // TODO remove this
+               print "<pre>{$info['curid']}</pre>";
+
                if ( $info ) {
                        $lastRedirect = isset( $data['query']['redirects'] )
                                ? count( $data['query']['redirects'] ) - 1
@@ -90,7 +93,7 @@
         * @return string
         */
        static function getProps() {
-               return 
'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata';
+               return 
'timestamp|user|comment|url|size|sha1|metadata|mime|mediatype|extmetadata|curid';
        }
 
        // Dummy functions...
@@ -219,6 +222,13 @@
        }
 
        /**
+        * @return int|null
+        */
+       public function getPageId() {
+               return isset( $this->mInfo['curid'] ) ? intval( 
$this->mInfo['curid'] ) : null;
+       }
+
+       /**
         * @param string $type
         * @return int|null|string
         */
diff --git a/includes/filerepo/file/LocalFile.php 
b/includes/filerepo/file/LocalFile.php
index 0da1ae8..7fb5282 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -758,6 +758,16 @@
        }
 
        /**
+        * @return int
+        * @throws MWException
+        */
+       function getPageId() {
+               $page = WikiPage::factory( $this->title );
+
+               return $page->getId();
+       }
+
+       /**
         * Get handler-specific metadata
         * @return string
         */

-- 
To view, visit https://gerrit.wikimedia.org/r/262415
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f00b986e6095bdb9b8d6af6fbc5b01995227e02
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Victorbarbu <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to