From: jenkins-bot Date: Fri, 29 Aug 2014 19:45:06 +0000 (+0000) Subject: Merge "Make "/*@noflip*/ /*@embed*/" annotation work" X-Git-Tag: 1.31.0-rc.0~14221 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=08e50bcecd32e6646b2a07a356517feb733aad78;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Make "/*@noflip*/ /*@embed*/" annotation work" --- 08e50bcecd32e6646b2a07a356517feb733aad78 diff --combined includes/OutputPage.php index fbd80c955f,c71c19bc07..a58a79a200 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@@ -449,14 -449,15 +449,14 @@@ class OutputPage extends ContextSource * @param string $version Style version of the file. Defaults to $wgStyleVersion */ public function addScriptFile( $file, $version = null ) { - global $wgStylePath, $wgStyleVersion; // See if $file parameter is an absolute URL or begins with a slash if ( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) { $path = $file; } else { - $path = "{$wgStylePath}/common/{$file}"; + $path = $this->getConfig()->get( 'StylePath' ) . "/common/{$file}"; } if ( is_null( $version ) ) { - $version = $wgStyleVersion; + $version = $this->getConfig()->get( 'StyleVersion' ); } $this->addScript( Html::linkedScript( wfAppendQuery( $path, $version ) ) ); } @@@ -732,12 -733,13 +732,12 @@@ * @return bool True if cache-ok headers was sent. */ public function checkLastModified( $timestamp ) { - global $wgCachePages, $wgCacheEpoch, $wgUseSquid, $wgSquidMaxage; - if ( !$timestamp || $timestamp == '19700101000000' ) { wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" ); return false; } - if ( !$wgCachePages ) { + $config = $this->getConfig(); + if ( !$config->get( 'CachePages' ) ) { wfDebug( __METHOD__ . ": CACHE DISABLED\n" ); return false; } @@@ -746,11 -748,11 +746,11 @@@ $modifiedTimes = array( 'page' => $timestamp, 'user' => $this->getUser()->getTouched(), - 'epoch' => $wgCacheEpoch + 'epoch' => $config->get( 'CacheEpoch' ) ); - if ( $wgUseSquid ) { + if ( $config->get( 'UseSquid' ) ) { // bug 44570: the core page itself may not change, but resources might - $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - $wgSquidMaxage ); + $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - $config->get( 'SquidMaxage' ) ); } wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) ); @@@ -1105,9 -1107,11 +1105,9 @@@ * default links */ public function setFeedAppendQuery( $val ) { - global $wgAdvertisedFeedTypes; - $this->mFeedLinks = array(); - foreach ( $wgAdvertisedFeedTypes as $type ) { + foreach ( $this->getConfig()->get( 'AdvertisedFeedTypes' ) as $type ) { $query = "feed=$type"; if ( is_string( $val ) ) { $query .= '&' . $val; @@@ -1123,7 -1127,9 +1123,7 @@@ * @param string $href URL */ public function addFeedLink( $format, $href ) { - global $wgAdvertisedFeedTypes; - - if ( in_array( $format, $wgAdvertisedFeedTypes ) ) { + if ( in_array( $format, $this->getConfig()->get( 'AdvertisedFeedTypes' ) ) ) { $this->mFeedLinks[$format] = $href; } } @@@ -1247,15 -1253,9 +1247,15 @@@ # Fetch existence plus the hiddencat property $dbr = wfGetDB( DB_SLAVE ); + $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_len', + 'page_is_redirect', 'page_latest', 'pp_value' ); + + if ( $this->getConfig()->get( 'ContentHandlerUseDB' ) ) { + $fields[] = 'page_content_model'; + } + $res = $dbr->select( array( 'page', 'page_props' ), - array( 'page_id', 'page_namespace', 'page_title', 'page_len', - 'page_is_redirect', 'page_latest', 'pp_value' ), + $fields, $lb->constructSet( 'page', $dbr ), __METHOD__, array(), @@@ -1611,7 -1611,7 +1611,7 @@@ * @deprecated since 1.24, use addParserOutputMetadata() instead. * @param ParserOutput $parserOutput */ - public function addParserOutputNoText( &$parserOutput ) { + public function addParserOutputNoText( $parserOutput ) { $this->addParserOutputMetadata( $parserOutput ); } @@@ -1623,7 -1623,7 +1623,7 @@@ * @since 1.24 * @param ParserOutput $parserOutput */ - public function addParserOutputMetadata( &$parserOutput ) { + public function addParserOutputMetadata( $parserOutput ) { $this->mLanguageLinks += $parserOutput->getLanguageLinks(); $this->addCategoryLinks( $parserOutput->getCategories() ); $this->mNewSectionLink = $parserOutput->getNewSection(); @@@ -1657,11 -1657,11 +1657,11 @@@ } // Hooks registered in the object - global $wgParserOutputHooks; + $parserOutputHooks = $this->getConfig()->get( 'ParserOutputHooks' ); foreach ( $parserOutput->getOutputHooks() as $hookInfo ) { list( $hookName, $data ) = $hookInfo; - if ( isset( $wgParserOutputHooks[$hookName] ) ) { - call_user_func( $wgParserOutputHooks[$hookName], $this, $parserOutput, $data ); + if ( isset( $parserOutputHooks[$hookName] ) ) { + call_user_func( $parserOutputHooks[$hookName], $this, $parserOutput, $data ); } } @@@ -1679,7 -1679,7 +1679,7 @@@ * @since 1.24 * @param ParserOutput $parserOutput */ - public function addParserOutputContent( &$parserOutput ) { + public function addParserOutputContent( $parserOutput ) { $this->addParserOutputText( $parserOutput ); $this->addModules( $parserOutput->getModules() ); @@@ -1696,7 -1696,7 +1696,7 @@@ * @since 1.24 * @param ParserOutput $parserOutput */ - public function addParserOutputText( &$parserOutput ) { + public function addParserOutputText( $parserOutput ) { $text = $parserOutput->getText(); wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) ); $this->addHTML( $text ); @@@ -1707,7 -1707,7 +1707,7 @@@ * * @param ParserOutput $parserOutput */ - function addParserOutput( &$parserOutput ) { + function addParserOutput( $parserOutput ) { $this->addParserOutputMetadata( $parserOutput ); $parserOutput->setTOCEnabled( $this->mEnableTOC ); @@@ -1811,17 -1811,17 +1811,17 @@@ * @return array */ function getCacheVaryCookies() { - global $wgCookiePrefix, $wgCacheVaryCookies; static $cookies; if ( $cookies === null ) { + $config = $this->getConfig(); $cookies = array_merge( array( - "{$wgCookiePrefix}Token", - "{$wgCookiePrefix}LoggedOut", + $config->get( 'CookiePrefix' ) . 'Token', + $config->get( 'CookiePrefix' ) . 'LoggedOut', "forceHTTPS", session_name() ), - $wgCacheVaryCookies + $config->get( 'CacheVaryCookies' ) ); wfRunHooks( 'GetCacheVaryCookies', array( $this, &$cookies ) ); } @@@ -1987,11 -1987,11 +1987,11 @@@ * @return string */ public function getFrameOptions() { - global $wgBreakFrames, $wgEditPageFrameOptions; - if ( $wgBreakFrames ) { + $config = $this->getConfig(); + if ( $config->get( 'BreakFrames' ) ) { return 'DENY'; - } elseif ( $this->mPreventClickjacking && $wgEditPageFrameOptions ) { - return $wgEditPageFrameOptions; + } elseif ( $this->mPreventClickjacking && $config->get( 'EditPageFrameOptions' ) ) { + return $config->get( 'EditPageFrameOptions' ); } return false; } @@@ -2000,9 -2000,10 +2000,9 @@@ * Send cache control HTTP headers */ public function sendCacheControl() { - global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgUseXVO; - $response = $this->getRequest()->response(); - if ( $wgUseETag && $this->mETag ) { + $config = $this->getConfig(); + if ( $config->get( 'UseETag' ) && $this->mETag ) { $response->header( "ETag: $this->mETag" ); } @@@ -2013,24 -2014,24 +2013,24 @@@ # maintain different caches for logged-in users and non-logged in ones $response->header( $this->getVaryHeader() ); - if ( $wgUseXVO ) { + if ( $config->get( 'UseXVO' ) ) { # Add an X-Vary-Options header for Squid with Wikimedia patches $response->header( $this->getXVO() ); } if ( $this->mEnableClientCache ) { if ( - $wgUseSquid && session_id() == '' && !$this->isPrintable() && + $config->get( 'UseSquid' ) && session_id() == '' && !$this->isPrintable() && $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() ) { - if ( $wgUseESI ) { + if ( $config->get( 'UseESI' ) ) { # We'll purge the proxy cache explicitly, but require end user agents # to revalidate against the proxy on each visit. # Surrogate-Control controls our Squid, Cache-Control downstream caches wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", 'log' ); # start with a shorter timeout for initial testing # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"'); - $response->header( 'Surrogate-Control: max-age=' . $wgSquidMaxage + $response->header( 'Surrogate-Control: max-age=' . $config->get( 'SquidMaxage' ) . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' ); $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' ); } else { @@@ -2070,7 -2071,8 +2070,7 @@@ * the object, let's actually output it: */ public function output() { - global $wgLanguageCode, $wgDebugRedirects, $wgMimeType, $wgVaryOnXFP, - $wgResponsiveImages; + global $wgLanguageCode; if ( $this->mDoNothing ) { return; @@@ -2079,7 -2081,6 +2079,7 @@@ wfProfileIn( __METHOD__ ); $response = $this->getRequest()->response(); + $config = $this->getConfig(); if ( $this->mRedirect != '' ) { # Standards require redirect URLs to be absolute @@@ -2090,19 -2091,19 +2090,19 @@@ if ( wfRunHooks( "BeforePageRedirect", array( $this, &$redirect, &$code ) ) ) { if ( $code == '301' || $code == '303' ) { - if ( !$wgDebugRedirects ) { + if ( !$config->get( 'DebugRedirects' ) ) { $message = HttpStatus::getMessage( $code ); $response->header( "HTTP/1.1 $code $message" ); } $this->mLastModified = wfTimestamp( TS_RFC2822 ); } - if ( $wgVaryOnXFP ) { + if ( $config->get( 'VaryOnXFP' ) ) { $this->addVaryHeader( 'X-Forwarded-Proto' ); } $this->sendCacheControl(); $response->header( "Content-Type: text/html; charset=utf-8" ); - if ( $wgDebugRedirects ) { + if ( $config->get( 'DebugRedirects' ) ) { $url = htmlspecialchars( $redirect ); print "\n\nRedirect\n\n\n"; print "

Location: $url

\n"; @@@ -2124,7 -2125,7 +2124,7 @@@ # Buffer output; final headers may depend on later processing ob_start(); - $response->header( "Content-type: $wgMimeType; charset=UTF-8" ); + $response->header( 'Content-type: ' . $config->get( 'MimeType' ) . '; charset=UTF-8' ); $response->header( 'Content-language: ' . $wgLanguageCode ); // Avoid Internet Explorer "compatibility view" in IE 8-10, so that @@@ -2153,7 -2154,7 +2153,7 @@@ ); // Support for high-density display images if enabled - if ( $wgResponsiveImages ) { + if ( $config->get( 'ResponsiveImages' ) ) { $coreModules[] = 'mediawiki.hidpi'; } @@@ -2496,9 -2497,9 +2496,9 @@@ $template * @param int $lag Slave lag */ public function showLagWarning( $lag ) { - global $wgSlaveLagWarning, $wgSlaveLagCritical; - if ( $lag >= $wgSlaveLagWarning ) { - $message = $lag < $wgSlaveLagCritical + $config = $this->getConfig(); + if ( $lag >= $config->get( 'SlaveLagWarning' ) ) { + $message = $lag < $config->get( 'SlaveLagCritical' ) ? 'lag-warn-normal' : 'lag-warn-high'; $wrap = Html::rawElement( 'div', array( 'class' => "mw-{$message}" ), "\n$1\n" ); @@@ -2585,7 -2586,7 +2585,7 @@@ * @return string The doctype, opening "", and head element. */ public function headElement( Skin $sk, $includeStyle = true ) { - global $wgContLang, $wgMimeType; + global $wgContLang; $userdir = $this->getLanguage()->getDir(); $sitedir = $wgContLang->getDir(); @@@ -2602,7 -2603,7 +2602,7 @@@ $ret .= "$openHead\n"; } - if ( !Html::isXmlMimeType( $wgMimeType ) ) { + if ( !Html::isXmlMimeType( $this->getConfig()->get( 'MimeType' ) ) ) { // Add // This should be before since it defines the charset used by // text including the text inside <title>. @@@ -2672,7 -2673,7 +2672,7 @@@ */ public function getResourceLoader() { if ( is_null( $this->mResourceLoader ) ) { - $this->mResourceLoader = new ResourceLoader(); + $this->mResourceLoader = new ResourceLoader( $this->getConfig() ); } return $this->mResourceLoader; } @@@ -2691,6 -2692,8 +2691,6 @@@ protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array(), $loadCall = false ) { - global $wgResourceLoaderUseESI; - $modules = (array)$modules; $links = array( @@@ -2726,7 -2729,6 +2726,7 @@@ // Create keyed-by-source and then keyed-by-group list of module objects from modules list $sortedModules = array(); $resourceLoader = $this->getResourceLoader(); + $resourceLoaderUseESI = $this->getConfig()->get( 'ResourceLoaderUseESI' ); foreach ( $modules as $name ) { $module = $resourceLoader->getModule( $name ); # Check that we're allowed to include this module on this page @@@ -2824,7 -2826,7 +2824,7 @@@ $moduleContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) ); $url = $resourceLoader->createLoaderURL( $source, $moduleContext, $extraQuery ); - if ( $useESI && $wgResourceLoaderUseESI ) { + if ( $useESI && $resourceLoaderUseESI ) { $esi = Xml::element( 'esi:include', array( 'src' => $url ) ); if ( $only == ResourceLoaderModule::TYPE_STYLES ) { $link = Html::inlineStyle( $esi ); @@@ -2901,6 -2903,8 +2901,6 @@@ * @return string HTML fragment */ function getHeadScripts() { - global $wgResourceLoaderExperimentalAsyncLoading; - // Startup - this will immediately load jquery and mediawiki modules $links = array(); $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true ); @@@ -2940,7 -2944,7 +2940,7 @@@ ); } - if ( $wgResourceLoaderExperimentalAsyncLoading ) { + if ( $this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) { $links[] = $this->getScriptsForBottomQueue( true ); } @@@ -2959,6 -2963,8 +2959,6 @@@ * @return string */ function getScriptsForBottomQueue( $inHead ) { - global $wgAllowUserJs; - // Scripts and messages "only" requests marked for bottom inclusion // If we're in the <head>, use load() calls rather than <script src="..."> tags // Messages should go first @@@ -2992,7 -2998,7 +2992,7 @@@ ); // Add user JS if enabled - if ( $wgAllowUserJs + if ( $this->getConfig()->get( 'AllowUserJs' ) && $this->getUser()->isLoggedIn() && $this->getTitle() && $this->getTitle()->isJsSubpage() @@@ -3031,13 -3037,15 +3031,13 @@@ * @return string */ function getBottomScripts() { - global $wgResourceLoaderExperimentalAsyncLoading; - // Optimise jQuery ready event cross-browser. // This also enforces $.isReady to be true at </body> which fixes the // mw.loader bug in Firefox with using document.write between </body> // and the DOMContentReady event (bug 47457). $html = Html::inlineScript( 'window.jQuery && jQuery.ready();' ); - if ( !$wgResourceLoaderExperimentalAsyncLoading ) { + if ( !$this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) { $html .= $this->getScriptsForBottomQueue( false ); } @@@ -3224,10 -3232,13 +3224,10 @@@ * @return array Array in format "link name or number => 'link html'". */ public function getHeadLinksArray() { - global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, - $wgSitename, $wgVersion, - $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, - $wgDisableLangConversion, $wgCanonicalLanguageLinks, - $wgRightsPage, $wgRightsUrl; + global $wgVersion; $tags = array(); + $config = $this->getConfig(); $canonicalUrl = $this->mCanonicalUrl; @@@ -3270,7 -3281,7 +3270,7 @@@ } # Universal edit button - if ( $wgUniversalEditButton && $this->isArticleRelated() ) { + if ( $config->get( 'UniversalEditButton' ) && $this->isArticleRelated() ) { $user = $this->getUser(); if ( $this->getTitle()->quickUserCan( 'edit', $user ) && ( $this->getTitle()->exists() || $this->getTitle()->quickUserCan( 'create', $user ) ) ) { @@@ -3295,17 -3306,17 +3295,17 @@@ # should not matter, but Konqueror (3.5.9 at least) incorrectly # uses whichever one appears later in the HTML source. Make sure # apple-touch-icon is specified first to avoid this. - if ( $wgAppleTouchIcon !== false ) { + if ( $config->get( 'AppleTouchIcon' ) !== false ) { $tags['apple-touch-icon'] = Html::element( 'link', array( 'rel' => 'apple-touch-icon', - 'href' => $wgAppleTouchIcon + 'href' => $config->get( 'AppleTouchIcon' ) ) ); } - if ( $wgFavicon !== false ) { + if ( $config->get( 'Favicon' ) !== false ) { $tags['favicon'] = Html::element( 'link', array( 'rel' => 'shortcut icon', - 'href' => $wgFavicon + 'href' => $config->get( 'Favicon' ) ) ); } @@@ -3317,7 -3328,7 +3317,7 @@@ 'title' => $this->msg( 'opensearch-desc' )->inContentLanguage()->text(), ) ); - if ( $wgEnableAPI ) { + if ( $config->get( 'EnableAPI' ) ) { # Real Simple Discovery link, provides auto-discovery information # for the MediaWiki API (and potentially additional custom API # support such as WordPress or Twitter-compatible APIs for a @@@ -3336,37 -3347,39 +3336,37 @@@ } # Language variants - if ( !$wgDisableLangConversion && $wgCanonicalLanguageLinks ) { + if ( !$config->get( 'DisableLangConversion' ) ) { $lang = $this->getTitle()->getPageLanguage(); if ( $lang->hasVariants() ) { - - $urlvar = $lang->getURLVariant(); - - if ( !$urlvar ) { - $variants = $lang->getVariants(); - foreach ( $variants as $_v ) { - $tags["variant-$_v"] = Html::element( 'link', array( - 'rel' => 'alternate', - 'hreflang' => wfBCP47( $_v ), - 'href' => $this->getTitle()->getLocalURL( array( 'variant' => $_v ) ) ) - ); - } - } else { - $canonicalUrl = $this->getTitle()->getLocalURL(); + $variants = $lang->getVariants(); + foreach ( $variants as $_v ) { + $tags["variant-$_v"] = Html::element( 'link', array( + 'rel' => 'alternate', + 'hreflang' => wfBCP47( $_v ), + 'href' => $this->getTitle()->getLocalURL( array( 'variant' => $_v ) ) ) + ); } } + # x-default link per https://support.google.com/webmasters/answer/189077?hl=en + $tags["variant-x-default"] = Html::element( 'link', array( + 'rel' => 'alternate', + 'hreflang' => 'x-default', + 'href' => $this->getTitle()->getLocalURL() ) ); } # Copyright $copyright = ''; - if ( $wgRightsPage ) { - $copy = Title::newFromText( $wgRightsPage ); + if ( $config->get( 'RightsPage' ) ) { + $copy = Title::newFromText( $config->get( 'RightsPage' ) ); if ( $copy ) { $copyright = $copy->getLocalURL(); } } - if ( !$copyright && $wgRightsUrl ) { - $copyright = $wgRightsUrl; + if ( !$copyright && $config->get( 'RightsUrl' ) ) { + $copyright = $config->get( 'RightsUrl' ); } if ( $copyright ) { @@@ -3377,7 -3390,7 +3377,7 @@@ } # Feeds - if ( $wgFeed ) { + if ( $config->get( 'Feed' ) ) { foreach ( $this->getSyndicationLinks() as $format => $link ) { # Use the page name for the title. In principle, this could # lead to issues with having the same name for different feeds @@@ -3399,31 -3412,31 +3399,31 @@@ # like to promote instead of the RC feed (maybe like a "Recent New Articles" # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined. # If so, use it instead. - if ( $wgOverrideSiteFeed ) { - foreach ( $wgOverrideSiteFeed as $type => $feedUrl ) { + $sitename = $config->get( 'Sitename' ); + if ( $config->get( 'OverrideSiteFeed' ) ) { + foreach ( $config->get( 'OverrideSiteFeed' ) as $type => $feedUrl ) { // Note, this->feedLink escapes the url. $tags[] = $this->feedLink( $type, $feedUrl, - $this->msg( "site-{$type}-feed", $wgSitename )->text() + $this->msg( "site-{$type}-feed", $sitename )->text() ); } } elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) { $rctitle = SpecialPage::getTitleFor( 'Recentchanges' ); - foreach ( $wgAdvertisedFeedTypes as $format ) { + foreach ( $config->get( 'AdvertisedFeedTypes' ) as $format ) { $tags[] = $this->feedLink( $format, $rctitle->getLocalURL( array( 'feed' => $format ) ), # For grep: 'site-rss-feed', 'site-atom-feed' - $this->msg( "site-{$format}-feed", $wgSitename )->text() + $this->msg( "site-{$format}-feed", $sitename )->text() ); } } } # Canonical URL - global $wgEnableCanonicalServerLink; - if ( $wgEnableCanonicalServerLink ) { + if ( $config->get( 'EnableCanonicalServerLink' ) ) { if ( $canonicalUrl !== false ) { $canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL ); } else { @@@ -3502,6 -3515,8 +3502,8 @@@ if ( $flip === 'flip' && $this->getLanguage()->isRTL() ) { # If wanted, and the interface is right-to-left, flip the CSS $style_css = CSSJanus::transform( $style_css, true, false ); + } else { + $style_css = CSSJanus::nullTransform( $style_css ); } $this->mInlineStyles .= Html::inlineStyle( $style_css ) . "\n"; } @@@ -3513,7 -3528,7 +3515,7 @@@ * @return string */ public function buildCssLinks() { - global $wgAllowUserCss, $wgContLang; + global $wgContLang; $this->getSkin()->setupSkinUserCss( $this ); @@@ -3538,7 -3553,7 +3540,7 @@@ $moduleStyles[] = 'user.groups'; // Per-user custom styles - if ( $wgAllowUserCss && $this->getTitle()->isCssSubpage() && $this->userCanPreview() ) { + if ( $this->getConfig()->get( 'AllowUserCss' ) && $this->getTitle()->isCssSubpage() && $this->userCanPreview() ) { // We're on a preview of a CSS subpage // Exclude this page from the user module in case it's in there (bug 26283) $link = $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_STYLES, false, @@@ -3552,6 -3567,8 +3554,8 @@@ $previewedCSS = $this->getRequest()->getText( 'wpTextbox1' ); if ( $this->getLanguage()->getDir() !== $wgContLang->getDir() ) { $previewedCSS = CSSJanus::transform( $previewedCSS, true, false ); + } else { + $previewedCSS = CSSJanus::nullTransform( $previewedCSS ); } $otherTags .= Html::inlineStyle( $previewedCSS ) . "\n"; } else { @@@ -3650,8 -3667,8 +3654,8 @@@ substr( $style, 0, 6 ) == 'https:' ) { $url = $style; } else { - global $wgStylePath, $wgStyleVersion; - $url = $wgStylePath . '/' . $style . '?' . $wgStyleVersion; + $config = $this->getConfig(); + $url = $config->get( 'StylePath' ) . '/' . $style . '?' . $config->get( 'StyleVersion' ); } $link = Html::linkedStyle( $url, $media ); diff --combined includes/resourceloader/ResourceLoaderFileModule.php index 0c84700ece,19b9dd7be4..6128f19c79 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@@ -859,7 -859,7 +859,7 @@@ class ResourceLoaderFileModule extends } if ( $this->getStyleSheetLang( $localPath ) === 'less' ) { - $style = $this->compileLESSFile( $localPath ); + $style = $this->compileLessFile( $localPath ); $this->hasGeneratedStyles = true; } else { $style = file_get_contents( $localPath ); @@@ -867,6 -867,8 +867,8 @@@ if ( $flip ) { $style = CSSJanus::transform( $style, true, false ); + } else { + $style = CSSJanus::nullTransform( $style ); } $localDir = dirname( $localPath ); $remoteDir = dirname( $remotePath ); @@@ -898,20 -900,61 +900,20 @@@ return $this->targets; } - /** - * Generate a cache key for a LESS file. - * - * The cache key varies on the file name and the names and values of global - * LESS variables. - * - * @since 1.22 - * @param string $fileName File name of root LESS file. - * @return string Cache key - */ - protected function getLESSCacheKey( $fileName ) { - $vars = json_encode( ResourceLoader::getLESSVars( $this->getConfig() ) ); - $hash = md5( $fileName . $vars ); - return wfMemcKey( 'resourceloader', 'less', $hash ); - } - /** * Compile a LESS file into CSS. * - * If invalid, returns replacement CSS source consisting of the compilation - * error message encoded as a comment. To save work, we cache a result object - * which comprises the compiled CSS and the names & mtimes of the files - * that were processed. lessphp compares the cached & current mtimes and - * recompiles as necessary. + * Keeps track of all used files and adds them to localFileRefs. * * @since 1.22 - * @throws Exception If Less encounters a parse error - * @throws MWException If Less compilation returns unexpection result + * @throws Exception If lessc encounters a parse error * @param string $fileName File path of LESS source * @return string CSS source */ - protected function compileLESSFile( $fileName ) { - $key = $this->getLESSCacheKey( $fileName ); - $cache = wfGetCache( CACHE_ANYTHING ); - - // The input to lessc. Either an associative array representing the - // cached results of a previous compilation, or the string file name if - // no cache result exists. - $source = $cache->get( $key ); - if ( !is_array( $source ) || !isset( $source['root'] ) ) { - $source = $fileName; - } - + protected function compileLessFile( $fileName ) { $compiler = ResourceLoader::getLessCompiler( $this->getConfig() ); - $result = null; - - $result = $compiler->cachedCompile( $source ); - - if ( !is_array( $result ) ) { - throw new MWException( 'LESS compiler result has type ' - . gettype( $result ) . '; array expected.' ); - } - - $this->localFileRefs += array_keys( $result['files'] ); - $cache->set( $key, $result ); - return $result['compiled']; + $result = $compiler->compileFile( $fileName ); + $this->localFileRefs += array_keys( $compiler->allParsedFiles() ); + return $result; } }