Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/239862
Change subject: resourceloader: Move getFileDependencies() to FileModule
......................................................................
resourceloader: Move getFileDependencies() to FileModule
Change-Id: I06b5da4144798197478c66e8b9ccd4cc62cf6fb6
---
M includes/resourceloader/ResourceLoaderFileModule.php
M includes/resourceloader/ResourceLoaderModule.php
2 files changed, 48 insertions(+), 37 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/62/239862/1
diff --git a/includes/resourceloader/ResourceLoaderFileModule.php
b/includes/resourceloader/ResourceLoaderFileModule.php
index 7fbc1cb..79ba7d0 100644
--- a/includes/resourceloader/ResourceLoaderFileModule.php
+++ b/includes/resourceloader/ResourceLoaderFileModule.php
@@ -417,22 +417,65 @@
);
// Collect referenced files
$this->localFileRefs = array_unique( $this->localFileRefs );
- // If the list has been modified since last time we cached it,
update the cache
+ $this->setFileDependencies( $context->getSkin(),
$this->localFileRefs );
+
+ return $styles;
+ }
+
+ /**
+ * Set the files this module depends on indirectly for a given skin.
+ *
+ * @param string $skin Skin name
+ * @param array $localFileRefs List of files
+ */
+ protected function setFileDependencies( $skin, $localFileRefs ) {
try {
- if ( $this->localFileRefs !==
$this->getFileDependencies( $context->getSkin() ) ) {
+ // If the list has been modified since last time we
cached it, update the cache
+ if ( $localFileRefs !== $this->getFileDependencies(
$skin ) ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->replace( 'module_deps',
array( array( 'md_module', 'md_skin' )
), array(
'md_module' => $this->getName(),
- 'md_skin' =>
$context->getSkin(),
- 'md_deps' =>
FormatJson::encode( $this->localFileRefs ),
+ 'md_skin' => $skin,
+ 'md_deps' =>
FormatJson::encode( $localFileRefs ),
)
);
}
} catch ( Exception $e ) {
wfDebugLog( 'resourceloader', __METHOD__ . ": failed to
update DB: $e" );
}
- return $styles;
+ }
+
+ /**
+ * Get the files this module depends on indirectly for a given skin.
+ * Currently these are only image files referenced by the module's CSS.
+ *
+ * @param string $skin Skin name
+ * @return array List of files
+ */
+ protected function getFileDependencies( $skin ) {
+ // Try in-object cache first
+ if ( isset( $this->fileDeps[$skin] ) ) {
+ return $this->fileDeps[$skin];
+ }
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $deps = $dbr->selectField( 'module_deps',
+ 'md_deps',
+ array(
+ 'md_module' => $this->getName(),
+ 'md_skin' => $skin,
+ ),
+ __METHOD__
+ );
+
+ if ( !is_null( $deps ) ) {
+ $this->fileDeps[$skin] = (array)FormatJson::decode(
$deps, true );
+ } else {
+ $this->fileDeps[$skin] = array();
+ }
+
+ return $this->fileDeps[$skin];
}
/**
diff --git a/includes/resourceloader/ResourceLoaderModule.php
b/includes/resourceloader/ResourceLoaderModule.php
index 1a4d1f1..19de7d7 100644
--- a/includes/resourceloader/ResourceLoaderModule.php
+++ b/includes/resourceloader/ResourceLoaderModule.php
@@ -373,38 +373,6 @@
}
/**
- * Get the files this module depends on indirectly for a given skin.
- * Currently these are only image files referenced by the module's CSS.
- *
- * @param string $skin Skin name
- * @return array List of files
- */
- public function getFileDependencies( $skin ) {
- // Try in-object cache first
- if ( isset( $this->fileDeps[$skin] ) ) {
- return $this->fileDeps[$skin];
- }
-
- $dbr = wfGetDB( DB_SLAVE );
- $deps = $dbr->selectField( 'module_deps',
- 'md_deps',
- array(
- 'md_module' => $this->getName(),
- 'md_skin' => $skin,
- ),
- __METHOD__
- );
-
- if ( !is_null( $deps ) ) {
- $this->fileDeps[$skin] = (array)FormatJson::decode(
$deps, true );
- } else {
- $this->fileDeps[$skin] = array();
- }
-
- return $this->fileDeps[$skin];
- }
-
- /**
* Set preloaded file dependency information. Used so we can load this
* information for all modules at once.
* @param string $skin Skin name
--
To view, visit https://gerrit.wikimedia.org/r/239862
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I06b5da4144798197478c66e8b9ccd4cc62cf6fb6
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