public function getContent() { wfProfileIn(__METHOD__); $processingTimeStart = null; if ($this->mForceProfile) { $processingTimeStart = microtime(true); } $hash = wfAssetManagerGetSASShash($this->mOid); $paramsHash = md5(urldecode(http_build_query($this->mParams, '', ' '))); $cacheId = "/Sass-{$paramsHash}-{$hash}-" . self::CACHE_VERSION; $memc = F::App()->wg->Memc; $cachedContent = $memc->get($cacheId); if ($cachedContent) { $this->mContent = $cachedContent; } else { $this->processContent(); // This is the final pass on contents which, among other things, performs minification parent::getContent($processingTimeStart); // Prevent cache poisoning if we are serving sass from preview server if (getHostPrefix() == null && !$this->mForceProfile) { $memc->set($cacheId, $this->mContent); } } wfProfileOut(__METHOD__); return $this->mContent; }
/** * Creates a new SassService object based on the Sass source provided. * Please use static constructors instead of calling this constructor directly. * * @param Source $source */ public function __construct(Source $source) { parent::__construct(); $this->source = $source; // set up default cache variant if (!empty($this->wg->DevelEnvironment)) { $this->setCacheVariant("dev-{$this->wg->DevelEnvironmentName}"); } else { $hostPrefix = getHostPrefix(); if ($hostPrefix != null) { $this->setCacheVariant("staging-{$hostPrefix}"); } } }
public function getContent($processingTimeStart = null) { global $IP, $wgEnableSASSSourceMaps; wfProfileIn(__METHOD__); $processingTimeStart = null; if ($this->mForceProfile) { $processingTimeStart = microtime(true); } $memc = F::App()->wg->Memc; $this->mContent = null; $content = null; $sassService = null; $hasErrors = false; try { $sassService = SassService::newFromFile("{$IP}/{$this->mOid}"); $sassService->setSassVariables($this->mParams); $sassService->enableSourceMaps(!empty($wgEnableSASSSourceMaps)); $sassService->setFilters(SassService::FILTER_IMPORT_CSS | SassService::FILTER_CDN_REWRITE | SassService::FILTER_BASE64 | SassService::FILTER_JANUS); $cacheId = __CLASS__ . "-minified-" . $sassService->getCacheKey(); $content = $memc->get($cacheId); } catch (Exception $e) { $content = "/* {$e->getMessage()} */"; $hasErrors = true; } if ($content) { $this->mContent = $content; } else { // todo: add extra logging of AM request in case of any error try { $this->mContent = $sassService->getCss(false); } catch (Exception $e) { $this->mContent = $this->makeComment($e->getMessage()); $hasErrors = true; } // This is the final pass on contents which, among other things, performs minification parent::getContent($processingTimeStart); // Prevent cache poisoning if we are serving sass from preview server if (!empty($cacheId) && getHostPrefix() == null && !$this->mForceProfile && !$hasErrors) { $memc->set($cacheId, $this->mContent, WikiaResponse::CACHE_STANDARD); } } if ($hasErrors) { wfProfileOut(__METHOD__); throw new Exception($this->mContent); } wfProfileOut(__METHOD__); return $this->mContent; }
private function fixNotificationURL($url) { global $wgStagingList; $hostOn = getHostPrefix(); $hosts = $wgStagingList; foreach ($hosts as $host) { $prefix = 'http://' . $host . '.'; if (strpos($url, $prefix) !== false) { if (empty($hostOn)) { return str_replace($prefix, 'http://', $url); } else { return str_replace($prefix, 'http://' . $hostOn . '.', $url); } } } if (!empty($hostOn)) { return str_replace('http://', 'http://' . $hostOn . '.', $url); } return $url; }