mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-04-30 21:03:07 +00:00
Fixing Model::saveAll() PHP4 compatibility. Minor API change in __save(). __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
This commit is contained in:
parent
285fdc22c6
commit
6a34c9ef31
2 changed files with 8 additions and 7 deletions
cake
|
@ -1475,7 +1475,7 @@ class Model extends Overloadable {
|
||||||
if (Set::numeric(array_keys($data))) {
|
if (Set::numeric(array_keys($data))) {
|
||||||
while ($validates) {
|
while ($validates) {
|
||||||
foreach ($data as $key => $record) {
|
foreach ($data as $key => $record) {
|
||||||
if (!$currentValidates = $this->__save($this, $record, $options)) {
|
if (!$currentValidates = $this->__save($record, $options)) {
|
||||||
$validationErrors[$key] = $this->validationErrors;
|
$validationErrors[$key] = $this->validationErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,7 +1528,7 @@ class Model extends Overloadable {
|
||||||
if (isset($associations[$association])) {
|
if (isset($associations[$association])) {
|
||||||
switch ($associations[$association]) {
|
switch ($associations[$association]) {
|
||||||
case 'belongsTo':
|
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;
|
$data[$this->alias][$this->belongsTo[$association]['foreignKey']] = $this->{$association}->id;
|
||||||
} else {
|
} else {
|
||||||
$validationErrors[$association] = $this->{$association}->validationErrors;
|
$validationErrors[$association] = $this->{$association}->validationErrors;
|
||||||
|
@ -1541,7 +1541,7 @@ class Model extends Overloadable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$this->__save($this, $data, $options)) {
|
if (!$this->__save($data, $options)) {
|
||||||
$validationErrors[$this->alias] = $this->validationErrors;
|
$validationErrors[$this->alias] = $this->validationErrors;
|
||||||
$validates = false;
|
$validates = false;
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1559,7 @@ class Model extends Overloadable {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'hasOne':
|
case 'hasOne':
|
||||||
$values[$this->{$type}[$association]['foreignKey']] = $this->id;
|
$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;
|
$validationErrors[$association] = $this->{$association}->validationErrors;
|
||||||
$validates = false;
|
$validates = false;
|
||||||
}
|
}
|
||||||
|
@ -1632,12 +1632,12 @@ class Model extends Overloadable {
|
||||||
* @access private
|
* @access private
|
||||||
* @see Model::saveAll()
|
* @see Model::saveAll()
|
||||||
*/
|
*/
|
||||||
function __save(&$model, $data, $options) {
|
function __save($data, $options) {
|
||||||
if ($options['validate'] === 'first' || $options['validate'] === 'only') {
|
if ($options['validate'] === 'first' || $options['validate'] === 'only') {
|
||||||
if (!($model->create($data) && $model->validates($options))) {
|
if (!($this->create($data) && $this->validates($options))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} elseif (!($model->create(null) !== null && $model->save($data, $options))) {
|
} elseif (!($this->create(null) !== null && $this->save($data, $options))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1864,6 +1864,7 @@ class ValidationTest1 extends CakeTestModel {
|
||||||
*/
|
*/
|
||||||
function customValidatorWithParams($data, $validator, $or = true, $ignore_on_same = 'id') {
|
function customValidatorWithParams($data, $validator, $or = true, $ignore_on_same = 'id') {
|
||||||
$this->validatorParams = get_defined_vars();
|
$this->validatorParams = get_defined_vars();
|
||||||
|
unset($this->validatorParams['this']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue