mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Don't treat tables that substring match as associations
The table structure of: - packages - userpackages - georegions - userpackages_georegions Should not create a habtm between packages & georegions. Fixes #3532
This commit is contained in:
parent
a1035f720e
commit
eff4004261
1 changed files with 2 additions and 2 deletions
|
@ -627,7 +627,7 @@ class ModelTask extends BakeTask {
|
|||
$offset = strpos($otherTable, $model->table . '_');
|
||||
$otherOffset = strpos($otherTable, '_' . $model->table);
|
||||
|
||||
if ($offset !== false) {
|
||||
if ($offset === 0) {
|
||||
$offset = strlen($model->table . '_');
|
||||
$habtmName = $this->_modelName(substr($otherTable, $offset));
|
||||
$associations['hasAndBelongsToMany'][] = array(
|
||||
|
@ -637,7 +637,7 @@ class ModelTask extends BakeTask {
|
|||
'associationForeignKey' => $this->_modelKey($habtmName),
|
||||
'joinTable' => $otherTable
|
||||
);
|
||||
} elseif ($otherOffset !== false) {
|
||||
} elseif ($otherOffset === 0) {
|
||||
$habtmName = $this->_modelName(substr($otherTable, 0, $otherOffset));
|
||||
$associations['hasAndBelongsToMany'][] = array(
|
||||
'alias' => $habtmName,
|
||||
|
|
Loading…
Add table
Reference in a new issue