mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +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
|
@ -1475,7 +1475,7 @@ class Model extends Overloadable {
|
|||
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 @@ class Model extends Overloadable {
|
|||
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 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!$this->__save($this, $data, $options)) {
|
||||
if (!$this->__save($data, $options)) {
|
||||
$validationErrors[$this->alias] = $this->validationErrors;
|
||||
$validates = false;
|
||||
}
|
||||
|
@ -1559,7 +1559,7 @@ class Model extends Overloadable {
|
|||
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 @@ class Model extends Overloadable {
|
|||
* @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;
|
||||
|
|
|
@ -1864,6 +1864,7 @@ class ValidationTest1 extends CakeTestModel {
|
|||
*/
|
||||
function customValidatorWithParams($data, $validator, $or = true, $ignore_on_same = 'id') {
|
||||
$this->validatorParams = get_defined_vars();
|
||||
unset($this->validatorParams['this']);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue