Skip to content
This repository
Browse code

Change cake.php to allow cake libs at ROOT

Splice the ROOT path into the include_path for console apps.
This allows users to override the system include_path with a local
version of CakePHP.

Fixes #2613
  • Loading branch information...
commit d577d6b84e3ebaa13590c2c8c378e3f4886bccde 1 parent faeb7b4
Mark Story authored February 26, 2012
12  app/Console/cake.php
@@ -19,16 +19,8 @@
19 19
  */
20 20
 $ds = DIRECTORY_SEPARATOR;
21 21
 $dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
22  
-$found = false;
23  
-$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
24 22
 
25  
-foreach ($paths as $path) {
26  
-	if (file_exists($path . $ds . $dispatcher)) {
27  
-		$found = $path;
28  
-	}
29  
-}
30  
-
31  
-if (!$found && function_exists('ini_set')) {
  23
+if (function_exists('ini_set')) {
32 24
 	$root = dirname(dirname(dirname(__FILE__)));
33 25
 	ini_set('include_path', $root . $ds. 'lib' . PATH_SEPARATOR . ini_get('include_path'));
34 26
 }
@@ -36,6 +28,6 @@
36 28
 if (!include($dispatcher)) {
37 29
 	trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
38 30
 }
39  
-unset($paths, $path, $found, $dispatcher, $root, $ds);
  31
+unset($paths, $path, $dispatcher, $root, $ds);
40 32
 
41 33
 return ShellDispatcher::run($argv);
14  lib/Cake/Console/Templates/skel/Console/cake.php
@@ -19,23 +19,15 @@
19 19
  */
20 20
 $ds = DIRECTORY_SEPARATOR;
21 21
 $dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
22  
-$found = false;
23  
-$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
24 22
 
25  
-foreach ($paths as $path) {
26  
-	if (file_exists($path . $ds . $dispatcher)) {
27  
-		$found = $path;
28  
-	}
29  
-}
30  
-
31  
-if (!$found && function_exists('ini_set')) {
  23
+if (function_exists('ini_set')) {
32 24
 	$root = dirname(dirname(dirname(__FILE__)));
33  
-	ini_set('include_path', __CAKE_PATH__ . PATH_SEPARATOR . ini_get('include_path'));
  25
+	ini_set('include_path', $root . PATH_SEPARATOR . __CAKE_PATH__ . PATH_SEPARATOR . ini_get('include_path'));
34 26
 }
35 27
 
36 28
 if (!include($dispatcher)) {
37 29
 	trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
38 30
 }
39  
-unset($paths, $path, $found, $dispatcher, $root, $ds);
  31
+unset($paths, $path, $dispatcher, $root, $ds);
40 32
 
41 33
 return ShellDispatcher::run($argv);

0 notes on commit d577d6b

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