mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fix fullTablename(), ensure prefix prepending is only skipped when not on position 0 in tablename. Fixes #2750
This commit is contained in:
parent
77f698dbcd
commit
d2098828c6
2 changed files with 5 additions and 1 deletions
|
@ -922,7 +922,7 @@ class DboSource extends DataSource {
|
|||
if (is_object($model)) {
|
||||
$schemaName = $model->schemaName;
|
||||
$table = $model->tablePrefix . $model->table;
|
||||
} elseif (!empty($this->config['prefix']) && strpos($model, $this->config['prefix']) === false) {
|
||||
} elseif (!empty($this->config['prefix']) && strpos($model, $this->config['prefix']) !== 0) {
|
||||
$table = $this->config['prefix'] . strval($model);
|
||||
} else {
|
||||
$table = strval($model);
|
||||
|
|
|
@ -746,6 +746,10 @@ class DboSourceTest extends CakeTestCase {
|
|||
$Article->schemaName = null;
|
||||
$result = $noschema->fullTableName($Article, false, true);
|
||||
$this->assertEquals('articles', $result);
|
||||
|
||||
$this->testDb->config['prefix'] = 't_';
|
||||
$result = $this->testDb->fullTableName('post_tag', false, false);
|
||||
$this->assertEquals('t_post_tag', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue