From: jenkins-bot Date: Sat, 29 Sep 2018 02:05:51 +0000 (+0000) Subject: Merge "skins: Remove 'usemsgcache' and deprecate getDynamicStylesheetQuery" X-Git-Tag: 1.34.0-rc.0~3960 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=2323b0ba8161892714c3aba9fc6a4212397e0283;hp=93b235b2d39093943b539dbbf0bd216dca737ad7 Merge "skins: Remove 'usemsgcache' and deprecate getDynamicStylesheetQuery" --- diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index c32aa496ed..f540de5d14 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -468,6 +468,8 @@ because of Phabricator reports. * QuickTemplate::msgHtml() and BaseTemplate::msgHtml() have been deprecated as they promote bad practises. I18n messages should always be properly escaped. +* Skin::getDynamicStylesheetQuery() has been deprecated. It always + returns action=raw&ctype=text/css which callers should use directly. === Other changes in 1.32 === * (T198811) The following tables have had their UNIQUE indexes turned into diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index 463019f517..b5a6d3ac25 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -163,64 +163,35 @@ class RawAction extends FormlessAction { $title = $this->getTitle(); $request = $this->getRequest(); - // If it's a page in the MediaWiki namespace, we can just hit the message cache - if ( $request->getBool( 'usemsgcache' ) && $title->getNamespace() == NS_MEDIAWIKI ) { - // FIXME: The overhead and complexity of using MessageCache for serving - // source code is not worth the marginal gain in performance. This should - // instead use Revision::getRevisionText, which already has its own caching - // layer, which is good enough fine given action=raw only responds with - // a single page (no need for batch). - // - // Use of MessageCache: - // - is unsustainable (T193271), - // - can cause bugs due to "post-processing" (see MessageCache::get) not - // intending to apply to program source code, - // - causes uncertaintly around whether or not localisation default - // placeholders are, can, and should be used, or not. - $text = MessageCache::singleton()->get( - $title->getDBkey(), - // Yes, use the database. - true, - // Yes, use the content language. - true, - // Yes, the message key already contains the language in it ("/de", etc.) - true - ); - // If the local page doesn't exist, return a blank (not the default) - if ( $text === false ) { - $text = ''; - } - } else { - // Get it from the DB - $rev = Revision::newFromTitle( $title, $this->getOldId() ); - if ( $rev ) { - $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() ); - $request->response()->header( "Last-modified: $lastmod" ); + // Get it from the DB + $rev = Revision::newFromTitle( $title, $this->getOldId() ); + if ( $rev ) { + $lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() ); + $request->response()->header( "Last-modified: $lastmod" ); + + // Public-only due to cache headers + $content = $rev->getContent(); - // Public-only due to cache headers - $content = $rev->getContent(); + if ( $content === null ) { + // revision not found (or suppressed) + $text = false; + } elseif ( !$content instanceof TextContent ) { + // non-text content + wfHttpError( 415, "Unsupported Media Type", "The requested page uses the content model `" + . $content->getModel() . "` which is not supported via this interface." ); + die(); + } else { + // want a section? + $section = $request->getIntOrNull( 'section' ); + if ( $section !== null ) { + $content = $content->getSection( $section ); + } - if ( $content === null ) { - // revision not found (or suppressed) + if ( $content === null || $content === false ) { + // section not found (or section not supported, e.g. for JS, JSON, and CSS) $text = false; - } elseif ( !$content instanceof TextContent ) { - // non-text content - wfHttpError( 415, "Unsupported Media Type", "The requested page uses the content model `" - . $content->getModel() . "` which is not supported via this interface." ); - die(); } else { - // want a section? - $section = $request->getIntOrNull( 'section' ); - if ( $section !== null ) { - $content = $content->getSection( $section ); - } - - if ( $content === null || $content === false ) { - // section not found (or section not supported, e.g. for JS, JSON, and CSS) - $text = false; - } else { - $text = $content->getNativeData(); - } + $text = $content->getNativeData(); } } } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 858e124af4..455d38f243 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -810,8 +810,9 @@ class FileRepo { */ public function getDescriptionStylesheetUrl() { if ( isset( $this->scriptDirUrl ) ) { - return $this->makeUrl( 'title=MediaWiki:Filepage.css&' . - wfArrayToCgi( Skin::getDynamicStylesheetQuery() ) ); + // Must match canonical query parameter order for optimum caching + // See Title::getCdnUrls + return $this->makeUrl( 'title=MediaWiki:Filepage.css&action=raw&ctype=text/css' ); } return false; diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index e426f7f8c5..ed4045d487 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -414,17 +414,13 @@ abstract class Skin extends ContextSource { /** * Get the query to generate a dynamic stylesheet * + * @deprecated since 1.32 Use action=raw&ctype=text/css directly. * @return array */ public static function getDynamicStylesheetQuery() { - global $wgSquidMaxage; - return [ 'action' => 'raw', - 'maxage' => $wgSquidMaxage, - 'usemsgcache' => 'yes', 'ctype' => 'text/css', - 'smaxage' => $wgSquidMaxage, ]; } diff --git a/maintenance/dictionary/mediawiki.dic b/maintenance/dictionary/mediawiki.dic index ff06e49d4d..a0177b1737 100644 --- a/maintenance/dictionary/mediawiki.dic +++ b/maintenance/dictionary/mediawiki.dic @@ -4322,7 +4322,6 @@ useemail uselang uselivepreview usemod -usemsgcache usenewrc user useragent