Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing useless loop in Model::save()

  • Loading branch information...
commit 8375570f8aee3dbd7cea85762bebfcfe30ae2cec 1 parent 0c951b7
@markstory markstory authored
Showing with 10 additions and 15 deletions.
  1. +10 −15 cake/libs/model/model.php
View
25 cake/libs/model/model.php
@@ -1327,21 +1327,16 @@ function save($data = null, $validate = true, $fieldList = array()) {
if (!empty($this->id)) {
$success = (bool)$db->update($this, $fields, $values);
} else {
- foreach ($this->_schema as $field => $properties) {
- if ($this->primaryKey === $field) {
- $fInfo = $this->_schema[$field];
- $isUUID = ($fInfo['length'] == 36 &&
- ($fInfo['type'] === 'string' || $fInfo['type'] === 'binary')
- );
- if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
- if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
- $j = array_search($this->primaryKey, $fields);
- $values[$j] = String::uuid();
- } else {
- list($fields[], $values[]) = array($this->primaryKey, String::uuid());
- }
- }
- break;
+ $fInfo = $this->_schema[$this->primaryKey];
+ $isUUID = ($fInfo['length'] == 36 &&
+ ($fInfo['type'] === 'string' || $fInfo['type'] === 'binary')
+ );
+ if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
+ if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
+ $j = array_search($this->primaryKey, $fields);
+ $values[$j] = String::uuid();
+ } else {
+ list($fields[], $values[]) = array($this->primaryKey, String::uuid());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.