Merging fixes to trunk

Revision: [1796]
Adding missing layout error messages.
Changed more errors in View class to use the ErrorHandler class

Revision: [1795]
Added the missing error messages I found after RC 1 was built.
Corrected errors in the View class when helpers where not found.
Added error views for missing component classes and files.
Updated views for missing view classes and files

Revision: [1794]
Adding fix for Ticket #273

Revision: [1793]
Correcting loading order of required files in bake.php

Revision: [1792]
Added fix for Ticket #271

Revision: [1791]
Fix for Ticket #268 and Ticket #272

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1797 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-01-13 23:53:23 +00:00
parent bda9e5ac45
commit fb96b06394
15 changed files with 275 additions and 98 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.5.1790 RC 1
0.10.5.1797 RC 1

View file

@ -39,7 +39,7 @@
* release/app/.htaccess
* release/app/webroot/.htaccess
*/
//define ('BASE_URL', env('SCRIPT_NAME');
//define ('BASE_URL', env('SCRIPT_NAME'));
/**
* Set debug level here:

View file

@ -125,20 +125,18 @@ class Component extends Object
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->controller->base;
call_user_func_array(array(&$error, 'missingComponentClass'), $component);
exit();
return $this->cakeError('missingComponentClass',
array(array('className' => $this->controller->name,
'component' => $component,
'file' => $componentFn)));
}
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->controller->base;
call_user_func_array(array(&$error, 'missingComponentFile'), Inflector::underscore($component));
exit();
return $this->cakeError('missingComponentFile',
array(array('className' => $this->controller->name,
'component' => $component,
'file' => $componentFn)));
}
}
}

View file

@ -98,7 +98,6 @@ class ErrorHandler extends Object
$this->error(array('code'=>'404',
'name'=>'Not found',
'message'=>sprintf(__("The requested address %s was not found on this server."), $url, $message)));
}
/**
@ -176,13 +175,28 @@ class ErrorHandler extends Object
function missingView($params)
{
extract($params);
$this->controller->webroot = $webroot;
$this->controller->webroot = $this->_webroot();
$this->controller->set(array('controller' => $className,
'action' => $action,
'file' => $file,
'title' => 'Missing View'));
$this->controller->render('../errors/missingView');
}
/**
* Renders the Missing Layout web page.
*
*/
function missingLayout($params)
{
extract($params);
$this->controller->webroot = $this->_webroot();
$this->controller->layout = 'default';
$this->controller->set(array('file' => $file,
'title' => 'Missing Layout'));
$this->controller->render('../errors/missingLayout');
}
/**
* Renders the Missing Table web page.
*
@ -205,8 +219,8 @@ class ErrorHandler extends Object
function missingHelperFile($params)
{
extract($params);
$this->controller->webroot = $webroot;
$this->controller->set(array('helper' => Inflector::camelize($file) . "Helper",
$this->controller->webroot = $this->_webroot();
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
'file' => $file,
'title' => 'Missing Helper File'));
$this->controller->render('../errors/missingHelperFile');
@ -220,13 +234,47 @@ class ErrorHandler extends Object
function missingHelperClass($params)
{
extract($params);
$this->controller->webroot = $webroot;
$this->controller->set(array('helper' => Inflector::camelize($class) . "Helper",
'file' => Inflector::underscore($class),
$this->controller->webroot = $this->_webroot();
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
'file' => $file,
'title' => 'Missing Helper Class'));
$this->controller->render('../errors/missingHelperClass');
exit();
}
/**
* Renders the Missing Component file web page.
*
*/
function missingComponentFile($params)
{
extract($params);
$this->controller->webroot = $this->_webroot();
$this->controller->set(array('controller' => $className,
'component' => $component,
'file' => $file,
'title' => 'Missing Component File'));
$this->controller->render('../errors/missingComponentFile');
exit();
}
/**
* Renders the Missing Component class web page.
*
*/
function missingComponentClass($params)
{
extract($params);
$this->controller->webroot = $this->_webroot();
$this->controller->set(array('controller' => $className,
'component' => $component,
'file' => $file,
'title' => 'Missing Component Class'));
$this->controller->render('../errors/missingComponentClass');
exit();
}
/**
* Enter description here...
*

View file

@ -757,17 +757,17 @@ class Model extends Object
if (empty($this->id) && $this->hasField('created') && !in_array('created', $fields))
{
$fields[] = 'created';
$values[] = date("'Y-m-d H:i:s'");
$values[] = date('Y-m-d H:i:s');
}
if ($this->hasField('modified') && !in_array('modified', $fields))
{
$fields[] = 'modified';
$values[] = 'NOW()';
$values[] = date('Y-m-d H:i:s');
}
if ($this->hasField('updated') && !in_array('updated', $fields))
{
$fields[] = 'updated';
$values[] = 'NOW()';
$values[] = date('Y-m-d H:i:s');
}
if(!$this->exists())
@ -797,7 +797,8 @@ class Model extends Object
{
if($this->db->create($this, $fields, $values))
{
$this->id = $this->db->lastInsertId($this->table, $this->primaryKey);
$this->__insertID = $this->db->lastInsertId($this->table, $this->primaryKey);
$this->id = $this->__insertID;
if(!empty($joined))
{
if(!$this->id > 0 && isset($newID))

View file

@ -754,17 +754,17 @@ class Model extends Object
if (empty($this->id) && $this->hasField('created') && !in_array('created', $fields))
{
$fields[] = 'created';
$values[] = date("'Y-m-d H:i:s'");
$values[] = date('Y-m-d H:i:s');
}
if ($this->hasField('modified') && !in_array('modified', $fields))
{
$fields[] = 'modified';
$values[] = 'NOW()';
$values[] = date('Y-m-d H:i:s');
}
if ($this->hasField('updated') && !in_array('updated', $fields))
{
$fields[] = 'updated';
$values[] = 'NOW()';
$values[] = date('Y-m-d H:i:s');
}
if(!$this->exists())
@ -794,7 +794,8 @@ class Model extends Object
{
if($this->db->create($this, $fields, $values))
{
$this->id = $this->db->lastInsertId($this->table, $this->primaryKey);
$this->__insertID = $this->db->lastInsertId($this->table, $this->primaryKey);
$this->id = $this->__insertID;
if(!empty($joined))
{
if(!$this->id > 0 && isset($newID))

View file

@ -0,0 +1,57 @@
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.view.templates.errors
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<h1>Missing Component Class</h1>
<p class="error">You are seeing this error because the component class <em><?php echo $component."Component";?></em>
you have set in <?php echo $controller."Controller";?> can't be found or doesn't exist in <em><?php echo "app".DS."controllers".DS."components".DS.$file; ?></em>
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_component_class.thtml</code>
view file, a user-customizable error page for handling non-existent component classes.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<p>&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;class <?php echo $component;?>Component extends Object<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Your component functions here<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function <em>myComponentFunction</em> ()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;<br />
</p>
in file : <?php echo "app".DS."controllers".DS."components".DS.$file; ?>
</p>

View file

@ -0,0 +1,57 @@
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.view.templates.errors
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<h1>Missing Component File</h1>
<p class="error">You are seeing this error because the component file <em><?php echo "app".DS."controllers".DS."components".DS.$file; ?></em>
can't be found or doesn't exist.
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_component_file.thtml</code>
view file, a user-customizable error page for handling non-existent component class files.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<p>&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;class <?php echo $component;?>Component extends Object<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Your component functions here<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function <em>myComponentFunction</em> ()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;<br />
</p>
in file : <?php echo "app".DS."controllers".DS."components".DS.$file; ?>
</p>

View file

@ -51,14 +51,6 @@ view file, a user-customizable error page for handling invalid controller dispat
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;<br />
</p>
<p>
in file : <?php echo "app".DS."controllers".DS.Inflector::underscore($controller).".php"; ?>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this->controller);
?>
</pre>
<?php endif;?>
</p>

View file

@ -28,16 +28,10 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<?php
$missingClass = $this->controller->missingHelperClass;
$missingFile = $this->controller->missingHelperFile;
?>
<h1>Missing Helper Class</h1>
<p class="error">You are seeing this error because the view helper class <em><?php echo $missingClass;?></em>
can't be found or doesn't exist in <em><?php echo $missingFile;?></em>
<p class="error">You are seeing this error because the view helper class <em><?php echo $helperClass;?></em>
can't be found or doesn't exist in <em><?php echo "app".DS."views".DS."helpers".DS.$file; ?></em>
</p>
@ -45,21 +39,19 @@
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_helper_class.thtml</code>
view file, a user-customizable error page for handling non-existent view helper classes.</span>
</p>
<p>
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missingClass ." extends Helper {\n
// Your helper functions here
function <em>myHelperFunction</em> ()
{
}
}\n?&gt;</pre>"; ?>
in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
<p>&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;class <?php echo $helperClass;?> extends Helper<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Your helper functions heree<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function <em>myHelperFunction</em> ()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;<br />
</p>
<p>
<strong>Error</strong>: Unable to load helper class <em><?php echo $missingClass;?></em> in
<em>View::_loadHelpers</em>
in file : <?php echo "app".DS."views".DS."helpers".DS.$file; ?>
</p>

View file

@ -28,15 +28,9 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<?php
$missingClass = $this->controller->missingHelperClass;
$missingFile = $this->controller->missingHelperFile;
?>
<h1>Missing Helper File</h1>
<p class="error">You are seeing this error because the view helper file <em><?php echo $missingFile;?></em>
<p class="error">You are seeing this error because the view helper file <em><?php echo "app".DS."views".DS."helpers".DS.$file; ?></em>
can't be found or doesn't exist
</p>
@ -50,16 +44,15 @@ view file, a user-customizable error page for handling non-existent view helper
<strong>Fatal</strong>: Create the Class:
</p>
<p>
<?php echo "<pre>&lt;?php\n\nclass " . $missingClass ." extends Helper {\n
// Your helper functions here
function <em>myHelperFunction</em> ()
{
}
}\n?&gt;</pre>"; ?>
in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
<p>&lt;?php<br />
&nbsp;&nbsp;&nbsp;&nbsp;class <?php echo $helperClass;?> extends Helper<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Your helper functions heree<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function <em>myHelperFunction</em> ()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
?&gt;<br />
</p>
<p>
<strong>Error</strong>: Unable to load helper file <em><?php echo $missingFile.".php";?></em> in
<em>View::_loadHelpers</em>
in file : <?php echo "app".DS."views".DS."helpers".DS.$file; ?>
</p>

View file

@ -0,0 +1,40 @@
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.view.templates.errors
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<h1>Missing Layout</h1>
<p class="error">You are seeing this error because the layout file <em><?php echo $file;?></em>
can't be found or doesn't exist.
</p>
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_layout.thtml</code>
view file, a user-customizable error page for handling missing/invalid views during rendering.</span>
</p>

View file

@ -30,7 +30,7 @@
?>
<h1>Missing view</h1>
<p class="error">You are seeing this error because the view <em><?php echo $this->missingView;?></em>
<p class="error">You are seeing this error because the view <em><?php echo $file;?></em>
for action <em><?php echo $action;?></em>
in controller <em><?php echo $controller;?></em> could not be found.
</p>
@ -41,6 +41,6 @@ view file, a user-customizable error page for handling missing/invalid views dur
</p>
<p>
<strong>Fatal</strong>: Unable to load view file <em><?php echo $this->missingView;?></em> for
action <em><?php echo $this->missingView;?>::<?php echo $action;?></em>
<strong>Fatal</strong>: Unable to load view file <em><?php echo $file;?></em> for
action <em><?php echo $controller.'Controller';?>::<?php echo $action;?>()</em>
</p>

View file

@ -304,10 +304,11 @@ class View extends Object
if (strpos($action, 'missingView') === false)
{
$controller = $this;
$controller->missingView = $viewFileName;
$controller->action = $action;
call_user_func_array(array(&$controller, 'missingView'), empty($params['pass'])? null: $params['pass']);
return $this->cakeError('missingView',
array(array('className' => $this->controller->name,
'action' => $action,
'file' => $viewFileName)));
$isFatal = isset($this->isFatal) ? $this->isFatal : false;
if (!$isFatal)
{
@ -437,8 +438,9 @@ class View extends Object
}
else
{
trigger_error(sprintf(__("Could not find layout %s (expected %s), create it first"), $this->layout, $layout_fn), E_USER_ERROR);
return false;
return $this->cakeError('missingLayout',
array(array('layout' => $this->layout,
'file' => $layout_fn)));
}
}
@ -644,11 +646,9 @@ class View extends Object
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperFile'), Inflector::underscore($helper));
exit();
return $this->cakeError('missingHelperFile',
array(array('helper' => $helper,
'file' => Inflector::underscore($helper).'.php')));
}
}
@ -678,11 +678,9 @@ class View extends Object
}
else
{
$error =& new Controller();
$error->autoLayout = true;
$error->base = $this->base;
call_user_func_array(array(&$error, 'missingHelperClass'), $helper);
exit();
return $this->cakeError('missingHelperClass',
array(array('helper' => $helper,
'file' => Inflector::underscore($helper).'.php')));
}
}
}

View file

@ -4,20 +4,20 @@
/**
* Bake startup script
*
*
* Invokes the Bake class with given parameters.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, Cake Software Foundation, Inc.
* Copyright (c) 2005, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @filesource
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
@ -36,8 +36,8 @@ define ('DS', DIRECTORY_SEPARATOR);
define ('ROOT', dirname(dirname(dirname(__FILE__))).DS);
define ('APP_DIR', 'app');
require (ROOT.'cake'.DS.'config'.DS.'paths.php');
require (ROOT.'cake'.DS.'basics.php');
require (ROOT.'cake'.DS.'config'.DS.'paths.php');
uses ('bake');
$waste = array_shift($argv);