From 09a4dcd5465868369d76388f0cfe11ddfd6a81a5 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 2 Jul 2015 20:59:16 -0400 Subject: [PATCH] CRM-16426 - Don't hard-fail if non-mini file is not where we expect --- CRM/Core/Resources.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index b0b1a926df..cd2945b5c5 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -195,10 +195,7 @@ class CRM_Core_Resources { $domain = ($translate === TRUE) ? $ext : $translate; $this->addString($this->strings->get($domain, $this->getPath($ext, $file), 'text/javascript'), $domain); } - // Use non-minified version if we are in debug mode - if (CRM_Core_Config::singleton()->debug) { - $file = str_replace('.min.js', '.js', $file); - } + $this->resolveFileName($file, $ext); return $this->addScriptUrl($this->getUrl($ext, $file, TRUE), $weight, $region); } @@ -413,10 +410,7 @@ class CRM_Core_Resources { * @return CRM_Core_Resources */ public function addStyleFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { - // Use non-minified version if we are in debug mode - if (CRM_Core_Config::singleton()->debug) { - $file = str_replace('.min.css', '.css', $file); - } + $this->resolveFileName($file, $ext); return $this->addStyleUrl($this->getUrl($ext, $file, TRUE), $weight, $region); } @@ -817,4 +811,19 @@ class CRM_Core_Resources { return $filters; } + /** + * In debug mode, look for a non-minified version of this file + * + * @param string $fileName + * @param string $extName + */ + private function resolveFileName(&$fileName, $extName) { + if (CRM_Core_Config::singleton()->debug && strpos($fileName, '.min.') !== FALSE) { + $nonMiniFile = str_replace('.min.', '.', $fileName); + if ($this->getPath($extName, $nonMiniFile)) { + $fileName = $nonMiniFile; + } + } + } + } -- 2.25.1