Skip to content

Commit

Permalink
Fixed phalcon#13058: missing placeholder creation with object values
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronHall committed Oct 31, 2018
1 parent 43b36e7 commit 4c4f6cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Fixed `Phalcon\Mvc\Model\Query::execute` to properly bind parameters to sub queries [#11605](https://github.com/phalcon/cphalcon/issues/11605)
- Added missing Volt tags to array helper in `Phalcon\Mvc\View\Engine\Volt\Compiler::functionCall` [#13447](https://github.com/phalcon/cphalcon/issues/13447)
- Fixed `Phalcon\Http\Request::getJsonRawBody` [#13501](https://github.com/phalcon/cphalcon/issues/13501). It will now return false when the body content is empty, as well as when it encounters an error whilst decoding the JSON content.

- Fixed missing placeholder creation when objects `__toString` method are invoked. `Phalcon\Db\Adapter::insert` and `Phalcon\Db\Adapter::update` [#13058](https://github.com/phalcon/cphalcon/issues/13058).

# [3.4.1](https://github.com/phalcon/cphalcon/releases/tag/v3.4.1) (2018-08-04)
- Changed `Phalcon\Cache\Backend\Redis` to support connection timeout parameter
Expand Down
43 changes: 21 additions & 22 deletions phalcon/db/adapter.zep
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,18 @@ abstract class Adapter implements AdapterInterface, EventsAwareInterface
for position, value in values {
if typeof value == "object" {
let placeholders[] = (string) value;
}

if typeof value == "null" {
let placeholders[] = "null";
} else {
if typeof value == "null" {
let placeholders[] = "null";
} else {
let placeholders[] = "?";
let insertValues[] = value;
if typeof dataTypes == "array" {
if !fetch bindType, dataTypes[position] {
throw new Exception("Incomplete number of bind types");
}
let bindDataTypes[] = bindType;
let placeholders[] = "?";
let insertValues[] = value;
if typeof dataTypes == "array" {
if !fetch bindType, dataTypes[position] {
throw new Exception("Incomplete number of bind types");
}
let bindDataTypes[] = bindType;
}
}
}
Expand Down Expand Up @@ -465,22 +465,21 @@ abstract class Adapter implements AdapterInterface, EventsAwareInterface
}

let escapedField = this->escapeIdentifier(field);

if typeof value == "object" {
let placeholders[] = escapedField . " = " . value;
let value = (string) value;
}

if typeof value == "null" {
let placeholders[] = escapedField . " = null";
} else {
if typeof value == "null" {
let placeholders[] = escapedField . " = null";
} else {
let updateValues[] = value;
if typeof dataTypes == "array" {
if !fetch bindType, dataTypes[position] {
throw new Exception("Incomplete number of bind types");
}
let bindDataTypes[] = bindType;
let updateValues[] = value;
if typeof dataTypes == "array" {
if !fetch bindType, dataTypes[position] {
throw new Exception("Incomplete number of bind types");
}
let placeholders[] = escapedField . " = ?";
let bindDataTypes[] = bindType;
}
let placeholders[] = escapedField . " = ?";
}
}

Expand Down

0 comments on commit 4c4f6cf

Please sign in to comment.