Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/215364
Change subject: [WIP] resourceloader: Use module content to build version hash
......................................................................
[WIP] resourceloader: Use module content to build version hash
This will become the new default.
TODO: Measure impact and disable in subclasses for which it would
be too slow when calling it for all modules in the startup module.
Likely candidates:
- ResourceLoaderFileModule (I/O; fs)
- ResourceLoaderWikiModule (I/O; db)
Change-Id: I782df43c50dfcfb7d7592f744e13a3a0430b0dc6
---
M includes/resourceloader/ResourceLoaderModule.php
1 file changed, 34 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/64/215364/1
diff --git a/includes/resourceloader/ResourceLoaderModule.php
b/includes/resourceloader/ResourceLoaderModule.php
index 1af52d0..3f678b6 100644
--- a/includes/resourceloader/ResourceLoaderModule.php
+++ b/includes/resourceloader/ResourceLoaderModule.php
@@ -574,22 +574,28 @@
$contextHash = $context->getHash();
if ( !array_key_exists( $contextHash, $this->versionHash ) ) {
- $summary = $this->getDefinitionSummary( $context );
- if ( !isset( $summary['_cacheEpoch'] ) ) {
- throw new Exception( 'getDefinitionSummary must
call parent method' );
- }
- $str = json_encode( $summary );
+ if ( $this->enableModuleContentVersion() ) {
+ // Detect changes directly
+ $str = json_encode( $this->getModuleContent(
$context ) );
+ } else {
+ // Infer changes based on definition and other
metrics
+ $summary = $this->getDefinitionSummary(
$context );
+ if ( !isset( $summary['_cacheEpoch'] ) ) {
+ throw new Exception(
'getDefinitionSummary must call parent method' );
+ }
+ $str = json_encode( $summary );
- $mtime = $this->getModifiedTime( $context );
- if ( $mtime !== null ) {
// Support: MediaWiki 1.25 and earlier
- $str .= strval( $mtime );
- }
+ $mtime = $this->getModifiedTime( $context );
+ if ( $mtime !== null ) {
+ $str .= strval( $mtime );
+ }
- $mhash = $this->getModifiedHash( $context );
- if ( $mhash !== null ) {
// Support: MediaWiki 1.25 and earlier
- $str .= strval( $mhash );
+ $mhash = $this->getModifiedHash( $context );
+ if ( $mhash !== null ) {
+ $str .= strval( $mhash );
+ }
}
$this->versionHash[ $contextHash ] =
ResourceLoader::makeHash( $str );
@@ -598,6 +604,22 @@
}
/**
+ * Whether this module should use getModuleContent() to make its
version hash.
+ *
+ * For performance reasons, modules that depend on database or file
system I/O
+ * to build module contents, may want to disable this. If this is
disabled,
+ * the module class in favour of having
+ * getVersionHash() use getDefinitionSummary() .
+ *
+ * See getVersionHash() for how this is used.
+ *
+ * @return bool
+ */
+ public function enableModuleContentVersion() {
+ return true;
+ }
+
+ /**
* Get the definition summary for this module.
*
* This is the method subclasses are recommended to use to track values
in their
--
To view, visit https://gerrit.wikimedia.org/r/215364
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I782df43c50dfcfb7d7592f744e13a3a0430b0dc6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits