From 7d72a6f249f174bc9b07a69456be457db6cca2eb Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 6 Feb 2013 20:31:15 -0500 Subject: [PATCH] Fix issue where bake was missing habtm associations If the current model is not the first table, habtm associations would be missed. This was caused by eff4004261a2bd05e4df54ee2af057c680ff50fc Refs #3532 Fixes #3605 --- lib/Cake/Console/Command/Task/ModelTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 4a00631ebb1..1627d6a624c 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -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)) {