Skip to content

Commit 721c438

Browse files
committed
Re-adding support for PHP's include_path.
Moving constants that are made of other constants into bootstrap.php
1 parent e083b21 commit 721c438

File tree

7 files changed

+113
-46
lines changed

7 files changed

+113
-46
lines changed

app/Console/cake.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
/**
44
* Command-line code generation utility to automate programmer chores.
55
*
6-
* Shell dispatcher class
7-
*
86
* PHP 5
97
*
108
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@@ -15,10 +13,29 @@
1513
*
1614
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
1715
* @link http://cakephp.org CakePHP(tm) Project
18-
* @package app.console
19-
* @since CakePHP(tm) v 1.2.0.5012
16+
* @package app.Console
17+
* @since CakePHP(tm) v 2.0
2018
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
2119
*/
22-
require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'lib'. DIRECTORY_SEPARATOR . 'Cake' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ShellDispatcher.php');
20+
$ds = DIRECTORY_SEPARATOR;
21+
$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
22+
$found = false;
23+
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
24+
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')) {
32+
$root = dirname(dirname(dirname(__FILE__)));
33+
ini_set('include_path', $root . $ds. 'lib' . PATH_SEPARATOR . ini_get('include_path'));
34+
}
35+
36+
if (!include($dispatcher)) {
37+
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
38+
}
39+
unset($paths, $path, $found, $dispatcher, $root, $ds);
2340

2441
return ShellDispatcher::run($argv);

app/webroot/index.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@
4444
if (!defined('APP_DIR')) {
4545
define('APP_DIR', basename(dirname(dirname(__FILE__))));
4646
}
47+
4748
/**
4849
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
4950
*
51+
* Un-comment this line to specify a fixed path to CakePHP.
52+
* This should point at the directory containg `Cake`.
53+
*
54+
* For ease of development CakePHP uses PHP's include_path. If you
55+
* cannot modify your include_path set this value.
5056
*/
51-
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
52-
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
53-
}
57+
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
5458

5559
/**
5660
* Editing below this line should NOT be necessary.
@@ -63,11 +67,20 @@
6367
if (!defined('WWW_ROOT')) {
6468
define('WWW_ROOT', dirname(__FILE__) . DS);
6569
}
66-
if (!defined('CORE_PATH')) {
67-
define('APP_PATH', ROOT . DS . APP_DIR . DS);
68-
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
70+
71+
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
72+
if (function_exists('ini_set')) {
73+
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
74+
}
75+
if (!include('Cake' . DS . 'bootstrap.php')) {
76+
$failed = true;
77+
}
78+
} else {
79+
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
80+
$failed = true;
81+
}
6982
}
70-
if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) {
83+
if (!empty($failed)) {
7184
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
7285
}
7386

app/webroot/test.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@
4444
if (!defined('APP_DIR')) {
4545
define('APP_DIR', basename(dirname(dirname(__FILE__))));
4646
}
47+
4748
/**
4849
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
4950
*
51+
* For ease of development CakePHP uses PHP's include_path. If you
52+
* need to cannot modify your include_path, you can set this path.
5053
*/
51-
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
52-
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
53-
}
54+
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
5455

5556
/**
5657
* Editing below this line should not be necessary.
@@ -63,11 +64,20 @@
6364
if (!defined('WWW_ROOT')) {
6465
define('WWW_ROOT', dirname(__FILE__) . DS);
6566
}
66-
if (!defined('CORE_PATH')) {
67-
define('APP_PATH', ROOT . DS . APP_DIR . DS);
68-
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
67+
68+
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
69+
if (function_exists('ini_set')) {
70+
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
71+
}
72+
if (!include('Cake' . DS . 'bootstrap.php')) {
73+
$failed = true;
74+
}
75+
} else {
76+
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
77+
$failed = true;
78+
}
6979
}
70-
if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) {
80+
if (!empty($failed)) {
7181
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
7282
}
7383

lib/Cake/Console/Templates/skel/webroot/index.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@
4444
if (!defined('APP_DIR')) {
4545
define('APP_DIR', basename(dirname(dirname(__FILE__))));
4646
}
47+
4748
/**
4849
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
4950
*
51+
* Un-comment this line to specify a fixed path to CakePHP.
52+
* This should point at the directory containg `Cake`.
53+
*
54+
* For ease of development CakePHP uses PHP's include_path. If you
55+
* need to squeeze a bit more performance you can set this path.
5056
*/
51-
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
52-
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
53-
}
57+
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
5458

5559
/**
5660
* Editing below this line should NOT be necessary.
@@ -63,11 +67,20 @@
6367
if (!defined('WWW_ROOT')) {
6468
define('WWW_ROOT', dirname(__FILE__) . DS);
6569
}
66-
if (!defined('CORE_PATH')) {
67-
define('APP_PATH', ROOT . DS . APP_DIR . DS);
68-
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
70+
71+
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
72+
if (function_exists('ini_set')) {
73+
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
74+
}
75+
if (!include('Cake' . DS . 'bootstrap.php')) {
76+
$failed = true;
77+
}
78+
} else {
79+
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
80+
$failed = true;
81+
}
6982
}
70-
if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) {
83+
if (!empty($failed)) {
7184
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
7285
}
7386

@@ -76,5 +89,6 @@
7689
}
7790

7891
App::uses('Dispatcher', 'Routing');
92+
7993
$Dispatcher = new Dispatcher();
8094
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));

lib/Cake/Console/Templates/skel/webroot/test.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@
4444
if (!defined('APP_DIR')) {
4545
define('APP_DIR', basename(dirname(dirname(__FILE__))));
4646
}
47+
4748
/**
4849
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
4950
*
51+
* For ease of development CakePHP uses PHP's include_path. If you
52+
* need to cannot modify your include_path, you can set this path.
5053
*/
51-
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
52-
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
53-
}
54+
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
5455

5556
/**
5657
* Editing below this line should not be necessary.
@@ -63,11 +64,20 @@
6364
if (!defined('WWW_ROOT')) {
6465
define('WWW_ROOT', dirname(__FILE__) . DS);
6566
}
66-
if (!defined('CORE_PATH')) {
67-
define('APP_PATH', ROOT . DS . APP_DIR . DS);
68-
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
67+
68+
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
69+
if (function_exists('ini_set')) {
70+
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
71+
}
72+
if (!include('Cake' . DS . 'bootstrap.php')) {
73+
$failed = true;
74+
}
75+
} else {
76+
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
77+
$failed = true;
78+
}
6979
}
70-
if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) {
80+
if (!empty($failed)) {
7181
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
7282
}
7383

lib/Cake/Console/cake.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
* @since CakePHP(tm) v 1.2.0.5012
2020
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
2121
*/
22-
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php');
22+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ShellDispatcher.php');
2323

2424
return ShellDispatcher::run($argv);

lib/Cake/bootstrap.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@
2323
}
2424
error_reporting(E_ALL & ~E_DEPRECATED);
2525

26-
/**
27-
* If the index.php file is used instead of an .htaccess file
28-
* or if the user can not set the web root to use the public
29-
* directory we will define ROOT there, otherwise we set it
30-
* here.
31-
*/
32-
if (!defined('ROOT')) {
33-
define('ROOT', '../');
34-
}
35-
if (!defined('WEBROOT_DIR')) {
36-
define('WEBROOT_DIR', 'webroot');
37-
}
26+
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
27+
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(__FILE__)));
28+
}
29+
30+
if (!defined('CORE_PATH')) {
31+
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
32+
}
33+
34+
if (!defined('APP_PATH')) {
35+
define('APP_PATH', ROOT . DS . APP_DIR . DS);
36+
}
37+
38+
if (!defined('WEBROOT_DIR')) {
39+
define('WEBROOT_DIR', 'webroot');
40+
}
3841

3942
/**
4043
* Path to the cake directory.

0 commit comments

Comments
 (0)