Permalink
Browse files

no need for user to call setDocRoot()

  • Loading branch information...
1 parent b8a8ae6 commit 6d5a173664b373cdb6e5aeef7689f68fe7e745d0 @mrclay mrclay committed with Sep 4, 2011
Showing with 14 additions and 6 deletions.
  1. +0 −3 min/builder/index.php
  2. +1 −2 min/index.php
  3. +13 −1 min/lib/Minify.php
View
3 min/builder/index.php
@@ -228,9 +228,6 @@
$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
View
3 min/index.php
@@ -25,8 +25,7 @@
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;
View
14 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 @@ public static function setCache($cache = '', $fileLocking = true)
*/
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;
@@ -401,6 +412,7 @@ public static function setDocRoot($unsetPathInfo = false)
require_once 'Minify/Logger.php';
Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
}
+ self::$isDocRootSet = true;
}
/**

0 comments on commit 6d5a173

Please sign in to comment.