jenkins-bot has submitted this change and it was merged.

Change subject: No rev ID in path, it messes with web caches
......................................................................


No rev ID in path, it messes with web caches

Change-Id: Idb053067bef1c065ea42a6d444915c79d7bba397
---
M repo/includes/LinkedData/EntityDataRequestHandler.php
M repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
2 files changed, 17 insertions(+), 36 deletions(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/LinkedData/EntityDataRequestHandler.php 
b/repo/includes/LinkedData/EntityDataRequestHandler.php
index 58dad03..c7892bf 100644
--- a/repo/includes/LinkedData/EntityDataRequestHandler.php
+++ b/repo/includes/LinkedData/EntityDataRequestHandler.php
@@ -179,12 +179,6 @@
 
                //TODO: malformed revision IDs should trigger a code 400
 
-               // get revision from $doc or request param
-               if ( preg_match( '#:(\w+)$#', $doc, $m ) ) {
-                       $doc = preg_replace( '#:(\w+)$#', '', $doc );
-                       $revision = (int)$m[1];
-               }
-
                $revision = $request->getInt( 'oldid', $revision );
                $revision = $request->getInt( 'revision', $revision );
 
@@ -280,13 +274,12 @@
         *
         * @param EntityId $id       The entity
         * @param string   $format   The (normalized) format name, or ''
-        * @param int      $revision The revision ID (use 0 for current)
         */
-       public function purge( EntityId $id, $format = '', $revision = 0 ) {
+       public function purge( EntityId $id, $format = '' ) {
                if ( $this->useSquids ) {
                        //TODO: Purge all formats based on the ID, instead of 
just the one currently requested.
                        //TODO: Also purge when an entity gets edited, using 
the new TitleSquidURLs hook.
-                       $title = $this->getDocTitle( $id, $format, $revision );
+                       $title = $this->getDocTitle( $id, $format );
 
                        $urls = array();
                        $urls[] = $title->getInternalURL();
@@ -302,19 +295,14 @@
         *
         * @param EntityId $id       The entity
         * @param string   $format   The (normalized) format name, or ''
-        * @param int      $revision The revision ID (use 0 for current)
         *
         * @return string
         */
-       public function getDocName( EntityId $id, $format = '', $revision = 0 ) 
{
+       public function getDocName( EntityId $id, $format = '' ) {
                $doc = $this->entityIdFormatter->format( $id );
 
                //TODO: Use upper case everywhere. EntityIdFormatter should do 
the right thing.
                $doc = strtoupper( $doc );
-
-               if ( $revision > 0 ) {
-                       $doc .= ':' . $revision;
-               }
 
                if ( $format !== null && $format !== '' ) {
                        $ext = $this->serializationService->getExtension( 
$format );
@@ -335,12 +323,11 @@
         *
         * @param EntityId $id       The entity
         * @param string   $format   The (normalized) format name, or ''
-        * @param int      $revision The revision ID (use 0 for current)
         *
         * @return Title
         */
-       public function getDocTitle( EntityId $id, $format = '', $revision = 0 
) {
-               $doc = $this->getDocName( $id, $format, $revision );
+       public function getDocTitle( EntityId $id, $format = '' ) {
+               $doc = $this->getDocName( $id, $format );
 
                $name = $this->interfaceTitle->getPrefixedText();
                if ( $doc !== null && $doc !== '' ) {
@@ -414,19 +401,18 @@
                if ( $format === 'html' ) {
                        //\Wikibase\EntityContentFactory::singleton()
                        $title = $this->entityContentFactory->getTitleForId( 
$id );
-                       $params = '';
-
-                       if ( $revision > 0 ) {
-                               // Ugh, internal knowledge. Doesn't title have 
a better way to do this?
-                               $params = 'oldid=' . $revision;
-                       }
-
-                       $url = $title->getFullURL( $params );
                } else {
-                       $title = $this->getDocTitle( $id, $format, $revision );
-                       $url = $title->getFullURL();
+                       $title = $this->getDocTitle( $id, $format );
                }
 
+               $params = '';
+
+               if ( $revision > 0 ) {
+                       // Ugh, internal knowledge. Doesn't title have a better 
way to do this?
+                       $params = 'oldid=' . $revision;
+               }
+
+               $url = $title->getFullURL( $params );
                return $url;
        }
 
diff --git a/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php 
b/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
index da80cfa..7952f9e 100644
--- a/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
+++ b/repo/tests/phpunit/includes/LinkedData/EntityDataTestProvider.php
@@ -159,11 +159,6 @@
                                unset( $case[1]['id'] );
                        }
 
-                       if ( isset( $case[1]['revision'] ) ) {
-                               $case[0] .= ':' . $case[1]['revision'];
-                               unset( $case[1]['revision'] );
-                       }
-
                        if ( isset( $case[1]['format'] ) ) {
                                if ( $case[4] === 200 && preg_match( '!/!', 
$case[1]['format'] ) ) {
                                        // It's a mime type, so it will trigger 
a redirect to the canonical form
@@ -283,13 +278,13 @@
 
                // #27: /q5:1234.json does trigger a 301 to the correct rev
                $cases[] = array(
-                       '{lowertestitemid}:{testitemrev}.json',      // subpage
-                       array(), // parameters
+                       '{lowertestitemid}.json',      // subpage
+                       array( 'revision' => '{testitemrev}' ), // parameters
                        array(), // headers
                        '!!', // output regex
                        301,  // http code
                        array( // headers
-                               'Location' => 
'!{testitemid}:{testitemrev}\.json!'
+                               'Location' => 
'!{testitemid}\.json[\?&]oldid={testitemrev}!'
                        )
                );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb053067bef1c065ea42a6d444915c79d7bba397
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to