Skip to content

Commit

Permalink
Fix issue where bake was missing habtm associations
Browse files Browse the repository at this point in the history
If the current model is not the first table, habtm associations would be
missed. This was caused by eff4004

Refs #3532
Fixes #3605
  • Loading branch information
markstory committed Feb 7, 2013
1 parent 758d717 commit 7d72a6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -623,9 +623,9 @@ public function findHasAndBelongsToMany(Model $model, $associations) {
$offset = strpos($otherTable, $model->table . '_');
$otherOffset = strpos($otherTable, '_' . $model->table);

if ($offset === 0) {
if ($offset !== false) {
$tableName = substr($otherTable, strlen($model->table . '_'));
} elseif ($otherOffset === 0) {
} elseif ($otherOffset !== false) {
$tableName = substr($otherTable, 0, $otherOffset);
}
if ($tableName && in_array($tableName, $this->_tables)) {
Expand Down

0 comments on commit 7d72a6f

Please sign in to comment.