Permalink
Browse files

Revert "Fix null not stopping model callbacks."

This reverts commit 82a8400.

The previous change broke a number of tests as existing tests expect
that a return value of null will not stop events.
  • Loading branch information...
1 parent 82a8400 commit 7d2cbec79d8f966085c55ca30fa984158cb40153 @markstory markstory committed Sep 14, 2012
Showing with 1 addition and 44 deletions.
  1. +0 −4 lib/Cake/Event/CakeEventManager.php
  2. +1 −1 lib/Cake/Model/Model.php
  3. +0 −39 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -248,10 +248,6 @@ public function dispatch($event) {
if ($result === false) {
$event->stopPropagation();
}
- // TODO remove this in 3.0 as its a compatibility shim for model callbacks.
- if (isset($event->break, $event->breakOn) && in_array($result, (array)$event->breakOn)) {
- $event->stopPropagation();
- }
if ($result !== null) {
$event->result = $result;
}
View
@@ -1667,7 +1667,7 @@ public function save($data = null, $validate = true, $fieldList = array()) {
$event = new CakeEvent('Model.beforeSave', $this, array($options));
list($event->break, $event->breakOn) = array(true, array(false, null));
$this->getEventManager()->dispatch($event);
- if ($event->isStopped()) {
+ if (!$event->result) {
$this->whitelist = $_whitelist;
return false;
}
@@ -540,25 +540,6 @@ public function testBeforeValidateSaveAbortion() {
}
/**
- * test that beforeValidate returning false can abort saves.
- *
- * @return void
- */
- public function testBeforeValidateNullSaveAbortion() {
- $this->loadFixtures('Post');
- $Model = new CallbackPostTestModel();
- $Model->beforeValidateReturn = null;
-
- $data = array(
- 'title' => 'new article',
- 'body' => 'this is some text.'
- );
- $Model->create();
- $result = $Model->save($data);
- $this->assertFalse($result);
- }
-
-/**
* test that beforeSave returning false can abort saves.
*
* @return void
@@ -578,26 +559,6 @@ public function testBeforeSaveSaveAbortion() {
}
/**
- * Test that beforeSave returnning null can abort saves.
- *
- * @return void
- */
- public function testBeforeSaveNullAbort() {
- $this->loadFixtures('Post');
- $Model = new CallbackPostTestModel();
- $Model->beforeSaveReturn = null;
-
- $data = array(
- 'title' => 'new article',
- 'body' => 'this is some text.'
- );
- $Model->create();
- $result = $Model->save($data);
- $this->assertFalse($result);
-
- }
-
-/**
* testSaveField method
*
* @return void

0 comments on commit 7d2cbec

Please sign in to comment.