Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/64289
Change subject: Puring of cached output from Special:EntityData.
......................................................................
Puring of cached output from Special:EntityData.
This will cause Special:EntityData to purge HTTP caches
if action=purge is given in the URL. Note that currently,
only the presently requested format of the output is purged.
Change-Id: Ic13fb09ad5abbeafe2b527c07245cf20ea4f737a
---
M repo/includes/specials/SpecialEntityData.php
1 file changed, 51 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/89/64289/1
diff --git a/repo/includes/specials/SpecialEntityData.php
b/repo/includes/specials/SpecialEntityData.php
index fa0a084..c77418a 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -85,7 +85,9 @@
*/
public function execute( $subPage ) {
$revision = 0;
- $format = 'json';
+ $format = '';
+
+ $requestedSubPage = $subPage;
// get format from $subPage or request param
if ( preg_match( '#\.([-./\w]+)$#', $subPage, $m ) ) {
@@ -113,6 +115,15 @@
return;
}
+ //XXX: allow for logged in users only?
+ if ( $this->getRequest()->getText( 'action', 'purge' ) ) {
+ $this->purge( $id, $format, $revision );
+ }
+
+ if ( $format === null || $format === '' ) {
+ $format = 'json';
+ }
+
$repo = \Wikibase\Repo\WikibaseRepo::getDefaultInstance();
$this->rdfBaseURI = $repo->getRdfBaseURI();
$this->entityLookup =
\Wikibase\StoreFactory::getStore()->getEntityLookup();
@@ -123,6 +134,45 @@
}
/**
+ * Purges the entity data identified by the subPage parameter from any
HTTP caches.
+ *
+ * @param string $id
+ * @param string $format
+ * @param int $revision
+ */
+ protected function purge( $id, $format = '', $revision = 0 ) {
+ global $wgUseSquid;
+
+ if ( $wgUseSquid ) {
+ //TODO: purge all formats based on the ID, instead of
just the one currently requested
+ $subPage = $this->getSubPageName( $id, $format,
$revision );
+
+ $title = $this->getTitle( $subPage );
+
+ $urls = array();
+ $urls[] = $title->getInternalURL();
+
+ $u = new SquidUpdate( $urls );
+ $u->doUpdate();
+ }
+ }
+
+ public function getSubPageName( $id, $format, $revision ) {
+ //TODO: force canonical ID (upper- or lower case) by redirecting
+ $subPage = $id;
+
+ if ( $revision > 0 ) {
+ $subPage .= ':' . $revision;
+ }
+
+ if ( $format !== null && $format !== '' ) {
+ $subPage .= '.' . $format;
+ }
+
+ return $subPage;
+ }
+
+ /**
* Output entity data.
*
* @param string $format The name (mime type of file extension) of the
format to use
--
To view, visit https://gerrit.wikimedia.org/r/64289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic13fb09ad5abbeafe2b527c07245cf20ea4f737a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits