diff --git a/min/builder/index.php b/min/builder/index.php index deb0fea..a3c4e2f 100644 --- a/min/builder/index.php +++ b/min/builder/index.php @@ -228,9 +228,6 @@ $(function () { $content = ob_get_clean(); // setup Minify -if (0 === stripos(PHP_OS, 'win')) { - Minify::setDocRoot(); // we may be on IIS -} Minify::setCache( isset($min_cachePath) ? $min_cachePath : '' ,$min_cacheFileLocking diff --git a/min/index.php b/min/index.php index e36dfd5..501c8a0 100644 --- a/min/index.php +++ b/min/index.php @@ -25,8 +25,7 @@ Minify::setCache( if ($min_documentRoot) { $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot; -} elseif (0 === stripos(PHP_OS, 'win')) { - Minify::setDocRoot(); // IIS may need help + Minify::$isDocRootSet = true; } $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks; diff --git a/min/lib/Minify.php b/min/lib/Minify.php index a000706..5baa181 100644 --- a/min/lib/Minify.php +++ b/min/lib/Minify.php @@ -59,7 +59,14 @@ class Minify { * @var string $importWarning */ public static $importWarning = "/* See http://code.google.com/p/minify/wiki/CommonProblems#@imports_can_appear_in_invalid_locations_in_combined_CSS_files */\n"; - + + /** + * Has the DOCUMENT_ROOT been set in user code? + * + * @var bool + */ + public static $isDocRootSet = false; + /** * Specify a cache object (with identical interface as Minify_Cache_File) or * a path to use with Minify_Cache_File. @@ -160,6 +167,10 @@ class Minify { */ public static function serve($controller, $options = array()) { + if (! self::$isDocRootSet && 0 === stripos(PHP_OS, 'win')) { + self::setDocRoot(); + } + if (is_string($controller)) { // make $controller into object $class = 'Minify_Controller_' . $controller; @@ -400,6 +411,7 @@ class Minify { require_once 'Minify/Logger.php'; Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\""); } + self::$isDocRootSet = true; } /**