Skip to content
Permalink
Browse files

Adding return statement, preventing infinite loops when no default fi…

…elds are bound, and unbindTranslation() is called with no fields. Fixes #307
  • Loading branch information...
markstory committed Feb 12, 2010
1 parent 0611f1b commit 0ce14ceb7ea42b23ff809765545b7f101348458d
@@ -465,6 +465,9 @@ function bindTranslation(&$model, $fields, $reset = true) {
* @return bool
*/
function unbindTranslation(&$model, $fields = null) {
if (empty($fields) && empty($this->settings[$model->alias])) {
return false;
}
if (empty($fields)) {
return $this->unbindTranslation($model, $this->settings[$model->alias]);
}
@@ -877,5 +877,23 @@ function testTranslateTableWithPrefix() {
));
$this->assertEqual($result, $expected);
}
/**
* Test infinite loops not occuring with unbindTranslation()
*
* @return void
*/
function testUnbindTranslationInfinteLoop() {
$this->loadFixtures('Translate', 'TranslatedItem');
$TestModel =& new TranslatedItem();
$TestModel->Behaviors->detach('Translate');
$TestModel->actsAs = array();
$TestModel->Behaviors->attach('Translate');
$TestModel->bindTranslation(array('title', 'content'), true);
$result = $TestModel->unbindTranslation();
$this->assertFalse($result);
}
}
?>

0 comments on commit 0ce14ce

Please sign in to comment.
You can’t perform that action at this time.