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; }
protected function getFileModificationTime($fileName) { switch (self::getFileType($fileName)) { case self::FILE_TYPE_REGULAR: return filemtime($fileName); break; case self::FILE_TYPE_SASS: return SassService::newFromFile($fileName)->getModifiedTime(); break; } }