Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing Model::saveAll() PHP4 compatibility. Minor API change in __sav…

…e(). __save() no longer takes a model instance as the first parameter. Because of Model implementation details in PHP4 this caused broken references. Fixes #6389, #6223

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8204 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 6a34c9ef3152b442dc2d24babcbfefeb1eb8dc51 1 parent 285fdc2
@markstory markstory authored
View
14 cake/libs/model/model.php
@@ -1475,7 +1475,7 @@ function saveAll($data = null, $options = array()) {
if (Set::numeric(array_keys($data))) {
while ($validates) {
foreach ($data as $key => $record) {
- if (!$currentValidates = $this->__save($this, $record, $options)) {
+ if (!$currentValidates = $this->__save($record, $options)) {
$validationErrors[$key] = $this->validationErrors;
}
@@ -1528,7 +1528,7 @@ function saveAll($data = null, $options = array()) {
if (isset($associations[$association])) {
switch ($associations[$association]) {
case 'belongsTo':
- if ($this->__save($this->{$association}, $values, $options)) {
+ if ($this->{$association}->__save($values, $options)) {
$data[$this->alias][$this->belongsTo[$association]['foreignKey']] = $this->{$association}->id;
} else {
$validationErrors[$association] = $this->{$association}->validationErrors;
@@ -1541,7 +1541,7 @@ function saveAll($data = null, $options = array()) {
}
}
}
- if (!$this->__save($this, $data, $options)) {
+ if (!$this->__save($data, $options)) {
$validationErrors[$this->alias] = $this->validationErrors;
$validates = false;
}
@@ -1559,7 +1559,7 @@ function saveAll($data = null, $options = array()) {
switch ($type) {
case 'hasOne':
$values[$this->{$type}[$association]['foreignKey']] = $this->id;
- if (!$this->__save($this->{$association}, $values, $options)) {
+ if (!$this->{$association}->__save($values, $options)) {
$validationErrors[$association] = $this->{$association}->validationErrors;
$validates = false;
}
@@ -1632,12 +1632,12 @@ function saveAll($data = null, $options = array()) {
* @access private
* @see Model::saveAll()
*/
- function __save(&$model, $data, $options) {
+ function __save($data, $options) {
if ($options['validate'] === 'first' || $options['validate'] === 'only') {
- if (!($model->create($data) && $model->validates($options))) {
+ if (!($this->create($data) && $this->validates($options))) {
return false;
}
- } elseif (!($model->create(null) !== null && $model->save($data, $options))) {
+ } elseif (!($this->create(null) !== null && $this->save($data, $options))) {
return false;
}
return true;
View
1  cake/tests/cases/libs/model/models.php
@@ -1864,6 +1864,7 @@ function customValidationMethod($data) {
*/
function customValidatorWithParams($data, $validator, $or = true, $ignore_on_same = 'id') {
$this->validatorParams = get_defined_vars();
+ unset($this->validatorParams['this']);
return true;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.