Denny Vrandecic has submitted this change and it was merged. Change subject: Purging of cached output from Special:EntityData. ......................................................................
Purging 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, 46 insertions(+), 0 deletions(-) Approvals: Denny Vrandecic: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/specials/SpecialEntityData.php b/repo/includes/specials/SpecialEntityData.php index c086a97..a241509 100755 --- a/repo/includes/specials/SpecialEntityData.php +++ b/repo/includes/specials/SpecialEntityData.php @@ -120,6 +120,8 @@ $revision = 0; $format = ''; + $requestedSubPage = $subPage; + // get format from $subPage or request param if ( preg_match( '#\.([-./\w]+)$#', $subPage, $m ) ) { $subPage = preg_replace( '#\.([-./\w]+)$#', '', $subPage ); @@ -144,6 +146,11 @@ if ( $id === null || $id === '' ) { $this->showForm(); return; + } + + //XXX: allow for logged in users only? + if ( $this->getRequest()->getText( 'action', 'purge' ) ) { + $this->purge( $id, $format, $revision ); } if ( $format === null || $format === '' ) { @@ -178,6 +185,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; + } + + /** * Returns the list of supported MIME types that can be used to specify the * output format. * -- To view, visit https://gerrit.wikimedia.org/r/64289 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic13fb09ad5abbeafe2b527c07245cf20ea4f737a Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Denny Vrandecic <denny.vrande...@wikimedia.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits