Skip to content

Commit

Permalink
Fix for couchdb update when rev is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwoo committed Jan 19, 2013
1 parent b10bb30 commit 7c7832b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions data/source/http/adapter/CouchDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ public function read($query, array $options = array()) {
}
$path = "{$config['database']}/{$_path}";
$args = (array) $conditions + (array) $limit + (array) $order;
$result = (array) json_decode($conn->get($path, $args), true);
$result = $conn->get($path, $args);
$result = is_string($result) ? json_decode($result, true) : $result;
$data = $stats = array();

if (isset($result['_id'])) {
Expand Down Expand Up @@ -488,13 +489,10 @@ public static function enabled($feature = null) {
* @return array
*/
protected function _format(array $data) {
if (isset($data['_id'])) {
$data['id'] = $data['_id'];
}
if (isset($data['_rev'])) {
$data['rev'] = $data['_rev'];
foreach (array("id", "rev") as $key) {
$data[$key] = isset($data["_{$key}"]) ? $data["_{$key}"] : null;
unset($data["_{$key}"]);
}
unset($data['_id'], $data['_rev']);
return $data;
}
}
Expand Down

0 comments on commit 7c7832b

Please sign in to comment.