Skip to content

Commit 07e5ce5

Browse files
committed
fix soft delete
1 parent c240c4f commit 07e5ce5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

api.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,9 @@ protected function parseGetParameterArray($get,$name,$characters) {
11361136

11371137
protected function applyBeforeHandler(&$action,&$database,&$table,&$ids,&$callback,&$inputs) {
11381138
if (is_callable($callback,true)) {
1139-
$max = max(count($ids),count($inputs));
1139+
$max = count($ids)?:count($inputs);
11401140
for ($i=0;$i<$max;$i++) {
1141-
$id = isset($ids[$i])?$ids[$i]:false;
1141+
if (!isset($ids[$i])) $ids[$i] = false;
11421142
if (!isset($inputs[$i])) $inputs[$i] = false;
11431143
$callback($action,$database,$table,$id,$inputs[$i]);
11441144
}
@@ -1518,7 +1518,7 @@ protected function createObjects($inputs,$tables) {
15181518
}
15191519

15201520
protected function updateObject($key,$input,$filters,$tables) {
1521-
if (!$input) return false;
1521+
if (!$input) return null;
15221522
$input = (array)$input;
15231523
$table = $tables[0];
15241524
$sql = 'UPDATE ! SET ';
@@ -1538,10 +1538,10 @@ protected function updateObject($key,$input,$filters,$tables) {
15381538
}
15391539

15401540
protected function updateObjects($key,$inputs,$filters,$tables) {
1541-
if (!$inputs) return false;
1541+
if (!$inputs) return null;
15421542
$keyField = $key[1];
15431543
$keys = $key[0];
1544-
if (count($inputs)!=count($keys)) {
1544+
if (count(array_filter($inputs))!=count(array_filter($keys))) {
15451545
$this->exitWith404('subject');
15461546
}
15471547
$rows = array();
@@ -1587,7 +1587,7 @@ protected function deleteObjects($key,$filters,$tables) {
15871587
}
15881588

15891589
protected function incrementObject($key,$input,$filters,$tables,$fields) {
1590-
if (!$input) return false;
1590+
if (!$input) return null;
15911591
$input = (array)$input;
15921592
$table = $tables[0];
15931593
$sql = 'UPDATE ! SET ';
@@ -1614,10 +1614,10 @@ protected function incrementObject($key,$input,$filters,$tables,$fields) {
16141614
}
16151615

16161616
protected function incrementObjects($key,$inputs,$filters,$tables,$fields) {
1617-
if (!$inputs) return false;
1617+
if (!$inputs) return null;
16181618
$keyField = $key[1];
16191619
$keys = $key[0];
1620-
if (count($inputs)!=count($keys)) {
1620+
if (count(array_filter($inputs))!=count(array_filter($keys))) {
16211621
$this->exitWith404('subject');
16221622
}
16231623
$rows = array();

0 commit comments

Comments
 (0)