[MediaWiki-commits] [Gerrit] Simplify and cleanup maxIncludeCacheTime() code - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: Simplify and cleanup maxIncludeCacheTime() code .. Simplify and cleanup maxIncludeCacheTime() code * Follow-up to 7730dee6. * Let subclasses avoid having to check $wgMiserMode themselves. * Use the Config object instead of global variables. Change-Id: Ic48f5f5a7ed8e1d04b13922375fb7873adfa0c60 --- M includes/specialpage/SpecialPage.php M includes/specials/SpecialNewpages.php M includes/specials/SpecialRecentchanges.php 3 files changed, 12 insertions(+), 30 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 6624414..f478203 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -186,12 +186,14 @@ * false to use the parent page's cache settings */ public function maxIncludeCacheTime() { - global $wgMiserMode; - if ( !$wgMiserMode ) { - return 0; - } else { - return 60*60; - } + return $this->getConfig()->get( 'MiserMode' ) ? $this->getCacheTTL() : 0; + } + + /** +* @return int Seconds that this page can be cached +*/ + protected function getCacheTTL() { + return 60 * 60; } /** diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index ff9a899..41890f2 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -479,17 +479,7 @@ return 'changes'; } - /** -* How long to cache page when it is being included. -* -* @return int Time in seconds, 0 to disable caching altogether -*/ - public function maxIncludeCacheTime() { - global $wgMiserMode; - if ( !$wgMiserMode ) { - return 0; - } else { - return 60*5; - } + protected function getCacheTTL() { + return 60 * 5; } } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 36ccd4a..00e07bd 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -795,18 +795,8 @@ return true; } - /** -* How long to cache page when it is being included. -* -* @return int|bool Time in seconds, 0 to disable caching altogether -*/ - public function maxIncludeCacheTime() { - global $wgMiserMode; - if ( !$wgMiserMode ) { - return 0; - } else { - return 60*5; - } + protected function getCacheTTL() { + return 60 * 50; } } -- To view, visit https://gerrit.wikimedia.org/r/294424 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic48f5f5a7ed8e1d04b13922375fb7873adfa0c60 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron SchulzGerrit-Reviewer: Florianschmidtwelzow Gerrit-Reviewer: Krinkle Gerrit-Reviewer: Legoktm Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Simplify and cleanup maxIncludeCacheTime() code - change (mediawiki/core)
Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/294424 Change subject: Simplify and cleanup maxIncludeCacheTime() code .. Simplify and cleanup maxIncludeCacheTime() code * Follow-up to 7730dee6. * Let subclasses avoid having to check $wgMiserMode themselves. * Use the Config object instead of global variables. Change-Id: Ic48f5f5a7ed8e1d04b13922375fb7873adfa0c60 --- M includes/specialpage/SpecialPage.php M includes/specials/SpecialNewpages.php M includes/specials/SpecialRecentchanges.php 3 files changed, 12 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/24/294424/1 diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 6624414..f478203 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -186,12 +186,14 @@ * false to use the parent page's cache settings */ public function maxIncludeCacheTime() { - global $wgMiserMode; - if ( !$wgMiserMode ) { - return 0; - } else { - return 60*60; - } + return $this->getConfig()->get( 'MiserMode' ) ? $this->getCacheTTL() : 0; + } + + /** +* @return int Seconds that this page can be cached +*/ + protected function getCacheTTL() { + return 60 * 60; } /** diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index ff9a899..4f02263 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -479,17 +479,7 @@ return 'changes'; } - /** -* How long to cache page when it is being included. -* -* @return int Time in seconds, 0 to disable caching altogether -*/ - public function maxIncludeCacheTime() { - global $wgMiserMode; - if ( !$wgMiserMode ) { - return 0; - } else { - return 60*5; - } + public function getCacheTTL() { + return 60 * 5; } } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 36ccd4a..561bfa2 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -795,18 +795,8 @@ return true; } - /** -* How long to cache page when it is being included. -* -* @return int|bool Time in seconds, 0 to disable caching altogether -*/ - public function maxIncludeCacheTime() { - global $wgMiserMode; - if ( !$wgMiserMode ) { - return 0; - } else { - return 60*5; - } + public function getCacheTTL() { + return 60 * 50; } } -- To view, visit https://gerrit.wikimedia.org/r/294424 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic48f5f5a7ed8e1d04b13922375fb7873adfa0c60 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits