jenkins-bot has submitted this change and it was merged. Change subject: ResourceLoaderImageModule: Implement cache invalidation ......................................................................
ResourceLoaderImageModule: Implement cache invalidation Bug: T94733 Change-Id: I6ac2ef8d897813e560daa133b89a7932f8c1a362 --- M includes/resourceloader/ResourceLoaderImage.php M includes/resourceloader/ResourceLoaderImageModule.php M tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php 3 files changed, 44 insertions(+), 4 deletions(-) Approvals: Krinkle: Looks good to me, but someone else must approve Jdlrobson: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 12d1e82..bf68fdd 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -117,7 +117,7 @@ * @param ResourceLoaderContext $context Any context * @return string */ - protected function getPath( ResourceLoaderContext $context ) { + public function getPath( ResourceLoaderContext $context ) { $desc = $this->descriptor; if ( is_string( $desc ) ) { return $this->basePath . '/' . $desc; diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index bf6a7dd..7efdb26 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -304,6 +304,49 @@ } /** + * Get the definition summary for this module. + * + * @param ResourceLoaderContext $context + * @return array + */ + public function getDefinitionSummary( ResourceLoaderContext $context ) { + $summary = parent::getDefinitionSummary( $context ); + foreach ( array( + 'localBasePath', + 'images', + 'variants', + 'prefix', + 'selectorWithoutVariant', + 'selectorWithVariant', + ) as $member ) { + $summary[$member] = $this->{$member}; + }; + return $summary; + } + + /** + * Get the last modified timestamp of this module. + * + * @param ResourceLoaderContext $context Context in which to calculate + * the modified time + * @return int UNIX timestamp + */ + public function getModifiedTime( ResourceLoaderContext $context ) { + $files = array(); + foreach ( $this->getImages() as $name => $image ) { + $files[] = $image->getPath( $context ); + } + + $files = array_values( array_unique( $files ) ); + $filesMtime = max( array_map( array( __CLASS__, 'safeFilemtime' ), $files ) ); + + return max( + $filesMtime, + $this->getDefinitionMtime( $context ) + ); + } + + /** * Extract a local base path from module definition information. * * @param array $options Module definition diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php index 758cfe1..cc121ba 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderImageTest.php @@ -109,9 +109,6 @@ class ResourceLoaderImageTestable extends ResourceLoaderImage { // Make some protected methods public - public function getPath( ResourceLoaderContext $context ) { - return parent::getPath( $context ); - } public function massageSvgPathdata( $svg ) { return parent::massageSvgPathdata( $svg ); } -- To view, visit https://gerrit.wikimedia.org/r/201267 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6ac2ef8d897813e560daa133b89a7932f8c1a362 Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits