Fixing display of core error messages

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4877 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-04-18 16:39:11 +00:00
parent 4b7e496446
commit bb8c52dac0
14 changed files with 73 additions and 62 deletions

View file

@ -75,7 +75,7 @@
}
}
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
trigger_error("Can't find CakePHP core. 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);
trigger_error(__("Can't find CakePHP core. 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.", true), E_USER_ERROR);
}
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
} else {

View file

@ -638,7 +638,7 @@
* @return array
*/
function normalizeList($list, $assoc = true, $sep = ',', $trim = true) {
trigger_error('normalizeList Deprecated: use Set::normalize');
trigger_error(__('normalizeList Deprecated: use Set::normalize', true), E_USER_WARNING);
if (is_string($list)) {
$list = explode($sep, $list);
if ($trim) {
@ -1420,7 +1420,7 @@
* @see Set::countDim
*/
function countdim($array) {
trigger_error(__('Deprecated: Use Set::countDim instead'), E_USER_WARNING);
trigger_error(__('Deprecated: Use Set::countDim instead', true), E_USER_WARNING);
if (is_array(reset($array))) {
$return = countdim(reset($array)) + 1;
} else {

View file

@ -306,7 +306,7 @@ class AuthComponent extends Object {
*/
function _setDefaults() {
if (empty($this->userModel)) {
trigger_error(__('Could not find $userModel. Please set AuthComponent::$userModel in beforeFilter().'), E_USER_WARNING);
trigger_error(__('Could not find $userModel. Please set AuthComponent::$userModel in beforeFilter().', true), E_USER_WARNING);
return false;
}
if (empty($this->loginAction)) {
@ -347,7 +347,7 @@ class AuthComponent extends Object {
} elseif (!empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]})) {
$this->objectModel = $controller->uses[0];
} else {
trigger_error(__('Could not find $objectModel. Please set AuthComponent::$objectModel in beforeFilter().'), E_USER_WARNING);
trigger_error(__('Could not find $objectModel. Please set AuthComponent::$objectModel in beforeFilter().', true), E_USER_WARNING);
return;
}
}
@ -377,7 +377,7 @@ class AuthComponent extends Object {
return true;
break;
default:
trigger_error(__('Auth::startup() - $validate is set to an incorrect value. Allowed settings are: "controller", "actions", "objects", "association" or null.'), E_USER_WARNING);
trigger_error(__('Auth::startup() - $validate is set to an incorrect value. Allowed settings are: "controller", "actions", "objects", "association" or null.', true), E_USER_WARNING);
break;
}
return $valid;
@ -594,7 +594,7 @@ class AuthComponent extends Object {
if (!ClassRegistry::isKeySet($this->userModel)) {
if (!loadModel(Inflector::underscore($this->userModel))) {
trigger_error(__('Auth::getUserModel() - $userModel is not set or could not be found') . $this->userModel, E_USER_WARNING);
trigger_error(__('Auth::getUserModel() - $userModel is not set or could not be found', true) . $this->userModel, E_USER_WARNING);
return null;
} else {
$model = $this->userModel;
@ -611,7 +611,7 @@ class AuthComponent extends Object {
}
if (empty($user)) {
trigger_error(__('Auth::getUserModel() - $userModel is not set or could not be found ') . $this->userModel, E_USER_WARNING);
trigger_error(__('Auth::getUserModel() - $userModel is not set or could not be found', true) . $this->userModel, E_USER_WARNING);
return null;
}
return $user;

View file

@ -144,7 +144,7 @@ class DB_ACL extends AclBase {
$save = array();
if ($perms == false) {
trigger_error(__('DB_ACL::allow() - Invalid node'), E_USER_WARNING);
trigger_error(__('DB_ACL::allow() - Invalid node', true), E_USER_WARNING);
return false;
}
@ -162,7 +162,7 @@ class DB_ACL extends AclBase {
if (in_array('_' . $action, $permKeys)) {
$save['_' . $action] = $value;
} else {
trigger_error(__('DB_ACL::allow() - Invalid ACO action'), E_USER_WARNING);
trigger_error(__('DB_ACL::allow() - Invalid ACO action', true), E_USER_WARNING);
return false;
}
}
@ -214,7 +214,7 @@ class DB_ACL extends AclBase {
* @return Aro
*/
function getAro($id = null) {
trigger_error(__('DB_ACL::getAro() - Usage deprecated. Use AclComponent::$Aro::node().'), E_USER_WARNING);
trigger_error(__('DB_ACL::getAro() - Usage deprecated. Use AclComponent::$Aro::node().', true), E_USER_WARNING);
return $this->__getObject($id, 'Aro');
}
/**
@ -224,7 +224,7 @@ class DB_ACL extends AclBase {
* @return Aco
*/
function getAco($id = null) {
trigger_error(__('DB_ACL::getAco() - Usage deprecated. Use AclComponent::$Aco::node().'), E_USER_WARNING);
trigger_error(__('DB_ACL::getAco() - Usage deprecated. Use AclComponent::$Aco::node().', true), E_USER_WARNING);
return $this->__getObject($id, 'Aco');
}
/**
@ -233,7 +233,7 @@ class DB_ACL extends AclBase {
*/
function __getObject($id = null, $object) {
if ($id == null) {
trigger_error(__('Null id provided in DB_ACL::get') . $object, E_USER_WARNING);
trigger_error(__('Null id provided in DB_ACL::get', true) . $object, E_USER_WARNING);
return null;
}

View file

@ -126,7 +126,6 @@ class AclNode extends AppModel {
$result = $this->query("{$query} " . $db->conditions($ref) ." ORDER BY {$type}.lft DESC", $this->cacheQueries);
if (!$result) {
pr($this->trace());
trigger_error("AclNode::node() - Couldn't find {$type} node identified by \"" . print_r($ref, true) . "\"", E_USER_WARNING);
}
}

View file

@ -351,7 +351,7 @@ class SecurityComponent extends Object {
}
} else {
// Server doesn't support digest-auth headers
trigger_error(__('SecurityComponent::loginCredentials() - Server does not support digest authentication'), E_USER_WARNING);
trigger_error(__('SecurityComponent::loginCredentials() - Server does not support digest authentication', true), E_USER_WARNING);
return null;
}

View file

@ -653,7 +653,7 @@ class Controller extends Object {
* @see Controller::set
*/
function _setTitle($pageTitle) {
trigger_error(__('Deprecated: Use Controller::set("title", "...") instead'), E_USER_WARNING);
trigger_error(__('Deprecated: Use Controller::set("title", "...") instead', true), E_USER_WARNING);
$this->pageTitle = $pageTitle;
}
/**

View file

@ -155,34 +155,38 @@ class Debugger extends Object {
$link = "document.getElementById(\"CakeStackTrace" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeStackTrace" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
$out = "<a href='javascript:void(0);' onclick='{$link}'><b>{$error}</b> ({$code})</a>: {$description} [<b>{$file}</b>, line <b>{$line}</b>]";
debug($out);
e('<div id="CakeStackTrace' . count($this->errors) . '" class="cake-stack-trace" style="display: none;">');
if (!empty($context)) {
$link = "document.getElementById(\"CakeErrorContext" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
e("<a href='javascript:void(0);' onclick='{$link}'>Context</a> | ");
$link = "document.getElementById(\"CakeErrorCode" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeErrorCode" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
e("<a href='javascript:void(0);' onclick='{$link}'>Code</a>");
if (Configure::read() > 0) {
debug($out);
e('<div id="CakeStackTrace' . count($this->errors) . '" class="cake-stack-trace" style="display: none;">');
if (!empty($context)) {
$link = "document.getElementById(\"CakeErrorContext" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
e("<a href='javascript:void(0);' onclick='{$link}'>Context</a> | ");
$link = "document.getElementById(\"CakeErrorCode" . count($this->errors) . "\").style.display = (document.getElementById(\"CakeErrorCode" . count($this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
e("<a href='javascript:void(0);' onclick='{$link}'>Code</a>");
if (!empty($helpCode)) {
e(" | <a href='{$this->helpPath}{$helpCode}' target='blank'>Help</a>");
}
if (!empty($helpCode)) {
e(" | <a href='{$this->helpPath}{$helpCode}' target='blank'>Help</a>");
}
e("<pre id=\"CakeErrorContext" . count($this->errors) . "\" class=\"cake-context\" style=\"display: none;\">");
foreach ($context as $var => $value) {
e("\${$var}\t=\t" . $this->exportVar($value, 1) . "\n");
e("<pre id=\"CakeErrorContext" . count($this->errors) . "\" class=\"cake-context\" style=\"display: none;\">");
foreach ($context as $var => $value) {
e("\${$var}\t=\t" . $this->exportVar($value, 1) . "\n");
}
e("</pre>");
}
e("</pre>");
}
$files = $this->trace(array('start' => 1, 'format' => 'points'));
$listing = Debugger::excerpt($files[0]['file'], $files[0]['line'] - 1, 2);
e("<div id=\"CakeErrorCode" . count($this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
pr(implode("\n", $listing));
e('</div>');
if (Configure::read() > 0) {
e("<div id=\"CakeErrorCode" . count($this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
pr(implode("\n", $listing));
e('</div>');
pr($this->trace(array('start' => 1)));
e('</div>');
pr($this->trace(array('start' => 1)));
e('</div>');
}
if (Configure::read('log')) {
CakeLog::write($level, "{$error} ({$code}): {$description} in [{$file}, line {$line}]");

View file

@ -277,7 +277,7 @@ function slashTerm($path) {
}
if (is_file($pathname)) {
trigger_error(__('chmodr() File exists'), E_USER_WARNING);
trigger_error(__('chmodr() File exists', true), E_USER_WARNING);
return false;
}
@ -304,7 +304,7 @@ function slashTerm($path) {
}
if (is_file($pathname)) {
trigger_error(__('mkdirr() File exists'), E_USER_WARNING);
trigger_error(__('mkdirr() File exists', true), E_USER_WARNING);
return false;
}
$nextPathname = substr($pathname, 0, strrpos($pathname, DS));

View file

@ -473,7 +473,7 @@ class DboMysql extends DboSource {
*/
function generateSchema($schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object'), E_USER_WARNING);
trigger_error(__('Invalid schema object', true), E_USER_WARNING);
return null;
}
$out = '';

View file

@ -158,7 +158,7 @@ class DboSource extends DataSource {
return $new;
}
/**
* Convenience method for DboSource::listSources().
* Convenience method for DboSource::listSources(). Returns source names in lowercase.
*
* @return array
*/
@ -318,7 +318,7 @@ class DboSource extends DataSource {
* @see DboSource::fetchRow
*/
function fetchArray() {
trigger_error(__('Deprecated: Use DboSource::fetchRow() instead'), E_USER_WARNING);
trigger_error(__('Deprecated: Use DboSource::fetchRow() instead', true), E_USER_WARNING);
return $this->fetchRow();
}
/**
@ -326,7 +326,7 @@ class DboSource extends DataSource {
* @see DboSource::fetchRow
*/
function one($sql) {
trigger_error(__('Deprecated: Use DboSource::fetchRow($sql) instead'), E_USER_WARNING);
trigger_error(__('Deprecated: Use DboSource::fetchRow($sql) instead', true), E_USER_WARNING);
return $this->fetchRow($sql);
}
/**

View file

@ -828,14 +828,16 @@ class Model extends Overloadable {
*
* @return array Array of table metadata
*/
function loadInfo() {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = $this->cacheSources;
function loadInfo($clear = false) {
if (!is_object($this->_tableInfo) || $clear) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = $this->cacheSources;
if (!is_object($this->_tableInfo) && $db->isInterfaceSupported('describe') && $this->useTable !== false) {
$this->_tableInfo = new Set($db->describe($this));
} elseif ($this->useTable === false) {
return new Set();
if ($db->isInterfaceSupported('describe') && $this->useTable !== false) {
$this->_tableInfo = new Set($db->describe($this, $clear));
} elseif ($this->useTable === false) {
$this->_tableInfo = new Set();
}
}
return $this->_tableInfo;
}
@ -1652,7 +1654,7 @@ class Model extends Overloadable {
*/
function validates($data = array()) {
if (!empty($data)) {
trigger_error(__('(Model::validates) Parameter usage is deprecated, set the $data property instead'), E_USER_WARNING);
trigger_error(__('(Model::validates) Parameter usage is deprecated, set the $data property instead', true), E_USER_WARNING);
}
$errors = $this->invalidFields($data);
if (is_array($errors)) {
@ -1674,7 +1676,7 @@ class Model extends Overloadable {
if (empty($data)) {
$data = $this->data;
} else {
trigger_error(__('(Model::invalidFields) Parameter usage is deprecated, set the $data property instead'), E_USER_WARNING);
trigger_error(__('(Model::invalidFields) Parameter usage is deprecated, set the $data property instead', true), E_USER_WARNING);
}
if (!isset($this->validate) || empty($this->validate)) {

View file

@ -671,7 +671,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::file
*/
function file($fieldName, $htmlAttributes = array()) {
trigger_error(__('(HtmlHelper::file) Deprecated: Use FormHelper::file instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::file) Deprecated: Use FormHelper::file instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -682,7 +682,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::submit
*/
function submit($caption = 'Submit', $htmlAttributes = array()) {
trigger_error(__('(HtmlHelper::submit) Deprecated: Use FormHelper::submit instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::submit) Deprecated: Use FormHelper::submit instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -693,7 +693,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::select
*/
function selectTag($fieldName, $optionElements, $selected = array(), $selectAttr = array(), $optionAttr = array(), $showEmpty = true) {
trigger_error(__('(HtmlHelper::selectTag) Deprecated: Use FormHelper::select instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::selectTag) Deprecated: Use FormHelper::select instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -704,7 +704,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::create
*/
function formTag($target = null, $type = 'post', $htmlAttributes = array()) {
trigger_error(__('(HtmlHelper::formTag) Deprecated: Use FormHelper::create instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::formTag) Deprecated: Use FormHelper::create instead', true), E_USER_WARNING);
$htmlAttributes['action'] = $this->url($target);
$htmlAttributes['method'] = low($type) == 'get' ? 'get' : 'post';
$type == 'file' ? $htmlAttributes['enctype'] = 'multipart/form-data' : null;
@ -723,7 +723,7 @@ class HtmlHelper extends AppHelper {
* @see HtmlHelper::link
*/
function linkEmail($title, $email = null, $options = null) {
trigger_error(__('(HtmlHelper::linkEmail) Deprecated: Use HtmlHelper::link instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::linkEmail) Deprecated: Use HtmlHelper::link instead', true), E_USER_WARNING);
// if no $email, then title contains the email.
if (empty($email)) {
$email = $title;
@ -761,7 +761,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::day
*/
function dayOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::dayOptionTag) Deprecated: Use FormHelper::day instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::dayOptionTag) Deprecated: Use FormHelper::day instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -772,7 +772,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::year
*/
function yearOptionTag($tagName, $value = null, $minYear = null, $maxYear = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::yearOptionTag) Deprecated: Use FormHelper::year instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::yearOptionTag) Deprecated: Use FormHelper::year instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -783,7 +783,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::month
*/
function monthOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::monthOptionTag) Deprecated: Use FormHelper::month instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::monthOptionTag) Deprecated: Use FormHelper::month instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -794,7 +794,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::hour
*/
function hourOptionTag($tagName, $value = null, $format24Hours = false, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::hourOptionTag) Deprecated: Use FormHelper::hour instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::hourOptionTag) Deprecated: Use FormHelper::hour instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -805,7 +805,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::minute
*/
function minuteOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::minuteOptionTag) Deprecated: Use FormHelper::minute instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::minuteOptionTag) Deprecated: Use FormHelper::minute instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -816,7 +816,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::meridian
*/
function meridianOptionTag($tagName, $value = null, $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::meridianOptionTag) Deprecated: Use FormHelper::meridian instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::meridianOptionTag) Deprecated: Use FormHelper::meridian instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;
@ -827,7 +827,7 @@ class HtmlHelper extends AppHelper {
* @see FormHelper::dateTime
*/
function dateTimeOptionTag($tagName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $selectAttr = null, $optionAttr = null, $showEmpty = true) {
trigger_error(__('(HtmlHelper::dateTimeOptionTag) Deprecated: Use FormHelper::dateTime instead'), E_USER_WARNING);
trigger_error(__('(HtmlHelper::dateTimeOptionTag) Deprecated: Use FormHelper::dateTime instead', true), E_USER_WARNING);
$this->__loadForm();
$form = new FormHelper();
$form->Html = $this;

View file

@ -82,6 +82,12 @@ class View extends Object {
* @var string
*/
var $field = null;
/**
* Suffix of current field this view context is attached to
*
* @var string
*/
var $fieldSuffix = null;
/**
* Name of current model ID this view context is attached to
*