mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Display datasource name in exceptions and error page.
When working with multiple databases, it's helpful to display the datasource name that is requested by a given model.
This commit is contained in:
parent
073d04931a
commit
408e785d5e
4 changed files with 6 additions and 5 deletions
|
@ -354,7 +354,7 @@ class MissingDatasourceException extends CakeException {
|
|||
* @package Cake.Error
|
||||
*/
|
||||
class MissingTableException extends CakeException {
|
||||
protected $_messageTemplate = 'Database table %s for model %s was not found.';
|
||||
protected $_messageTemplate = 'Table %s for model %s was not found in datasource %s.';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1029,7 +1029,8 @@ class Model extends Object {
|
|||
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
|
||||
throw new MissingTableException(array(
|
||||
'table' => $this->tablePrefix . $tableName,
|
||||
'class' => $this->alias
|
||||
'class' => $this->alias,
|
||||
'ds' => $this->useDbConfig,
|
||||
));
|
||||
}
|
||||
$this->_schema = null;
|
||||
|
|
|
@ -487,10 +487,10 @@ class ExceptionRendererTest extends CakeTestCase {
|
|||
404
|
||||
),
|
||||
array(
|
||||
new MissingTableException(array('table' => 'articles', 'class' => 'Article')),
|
||||
new MissingTableException(array('table' => 'articles', 'class' => 'Article', 'ds' => 'test')),
|
||||
array(
|
||||
'/<h2>Missing Database Table<\/h2>/',
|
||||
'/table <em>articles<\/em> for model <em>Article<\/em>/'
|
||||
'/Table <em>articles<\/em> for model <em>Article<\/em> was not found in datasource <em>test<\/em>/'
|
||||
),
|
||||
500
|
||||
),
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<h2><?php echo __d('cake_dev', 'Missing Database Table'); ?></h2>
|
||||
<p class="error">
|
||||
<strong><?php echo __d('cake_dev', 'Error'); ?>: </strong>
|
||||
<?php echo __d('cake_dev', 'Database table %1$s for model %2$s was not found.', '<em>' . $table . '</em>', '<em>' . $class . '</em>'); ?>
|
||||
<?php echo __d('cake_dev', 'Table %1$s for model %2$s was not found in datasource %3$s.', '<em>' . $table . '</em>', '<em>' . $class . '</em>', '<em>' . $ds . '</em>'); ?>
|
||||
</p>
|
||||
<p class="notice">
|
||||
<strong><?php echo __d('cake_dev', 'Notice'); ?>: </strong>
|
||||
|
|
Loading…
Reference in a new issue