Skip to content
This repository
Browse code

BUGFIX: Ensure site works if executed in a chrooted enviornment where…

… BASE_PATH is '/'. (#4069)
  • Loading branch information...
commit 213a08aac782c86ca82091d66236f0bd01d05297 1 parent a64715b
Sam Minnée authored April 11, 2012

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  core/Core.php
6  core/Core.php
@@ -124,7 +124,11 @@
124 124
  */
125 125
 if(!defined('BASE_PATH')) {
126 126
 	// Assuming that this file is sapphire/core/Core.php we can then determine the base path
127  
-	define('BASE_PATH', rtrim(dirname(dirname(dirname(__FILE__))), DIRECTORY_SEPARATOR));
  127
+	$candidateBasePath = rtrim(dirname(dirname(dirname(__FILE__))), DIRECTORY_SEPARATOR);
  128
+	// We can't have an empty BASE_PATH.  Making it / means that double-slashes occur in places but that's benign.
  129
+	// This likely only happens on chrooted environemnts
  130
+	if($candidateBasePath == '') $candidateBasePath = DIRECTORY_SEPARATOR;
  131
+	define('BASE_PATH', $candidateBasePath);
128 132
 }
129 133
 if(!defined('BASE_URL')) {
130 134
 	// Determine the base URL by comparing SCRIPT_NAME to SCRIPT_FILENAME and getting common elements

0 notes on commit 213a08a

Please sign in to comment.
Something went wrong with that request. Please try again.