Merge "skins: Remove 'usemsgcache' and deprecate getDynamicStylesheetQuery"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 29 Sep 2018 02:05:51 +0000 (02:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 29 Sep 2018 02:05:51 +0000 (02:05 +0000)
RELEASE-NOTES-1.32
includes/actions/RawAction.php
includes/filerepo/FileRepo.php
includes/skins/Skin.php
maintenance/dictionary/mediawiki.dic

index c32aa49..f540de5 100644 (file)
@@ -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
index 463019f..b5a6d3a 100644 (file)
@@ -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();
                                }
                        }
                }
index 858e124..455d38f 100644 (file)
@@ -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;
index e426f7f..ed4045d 100644 (file)
@@ -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,
                        ];
        }
 
index ff06e49..a0177b1 100644 (file)
@@ -4322,7 +4322,6 @@ useemail
 uselang
 uselivepreview
 usemod
-usemsgcache
 usenewrc
 user
 useragent