Skip to content

Commit 9fbe671

Browse files
committed
build fix for #744
1 parent 943a9a5 commit 9fbe671

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

api.include.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,17 +4555,21 @@ public function exception($exception): ResponseInterface
45554555

45564556
public function multi($results): ResponseInterface
45574557
{
4558-
$document = array();
4558+
$documents = array();
4559+
$errors = array();
45594560
$success = true;
45604561
foreach ($results as $i=>$result) {
45614562
if ($result instanceof \Throwable) {
4562-
$document[$i] = ErrorDocument::fromException($result);
4563+
$documents[$i] = null;
4564+
$errors[$i] = ErrorDocument::fromException($result);
45634565
$success = false;
45644566
} else {
4565-
$document[$i] = $result;
4567+
$documents[$i] = $result;
4568+
$errors[$i] = new ErrorDocument(new ErrorCode(0),'',null);
45664569
}
45674570
}
45684571
$status = $success ? ResponseFactory::OK : ResponseFactory::FAILED_DEPENDENCY;
4572+
$document = $success ? $documents : $errors;
45694573
$response = ResponseFactory::fromObject($status, $document);
45704574
foreach ($results as $i=>$result) {
45714575
if ($result instanceof \Throwable) {
@@ -9886,7 +9890,7 @@ public function serialize()
98869890

98879891
public function jsonSerialize()
98889892
{
9889-
return array_filter($this->serialize());
9893+
return array_filter($this->serialize(), function($v) {return $v!==null;});
98909894
}
98919895

98929896
public static function fromException(\Throwable $exception)
@@ -10062,7 +10066,7 @@ class ErrorCode
1006210066
const PASSWORD_TOO_SHORT = 1021;
1006310067

1006410068
private $values = [
10065-
9999 => ["%s", ResponseFactory::INTERNAL_SERVER_ERROR],
10069+
0000 => ["Success", ResponseFactory::OK],
1006610070
1000 => ["Route '%s' not found", ResponseFactory::NOT_FOUND],
1006710071
1001 => ["Table '%s' not found", ResponseFactory::NOT_FOUND],
1006810072
1002 => ["Argument count mismatch in '%s'", ResponseFactory::UNPROCESSABLE_ENTITY],
@@ -10085,6 +10089,7 @@ class ErrorCode
1008510089
1019 => ["Pagination forbidden", ResponseFactory::FORBIDDEN],
1008610090
1020 => ["User '%s' already exists", ResponseFactory::CONFLICT],
1008710091
1021 => ["Password too short (<%d characters)", ResponseFactory::UNPROCESSABLE_ENTITY],
10092+
9999 => ["%s", ResponseFactory::INTERNAL_SERVER_ERROR],
1008810093
];
1008910094

1009010095
public function __construct(int $code)

api.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4555,17 +4555,21 @@ public function exception($exception): ResponseInterface
45554555

45564556
public function multi($results): ResponseInterface
45574557
{
4558-
$document = array();
4558+
$documents = array();
4559+
$errors = array();
45594560
$success = true;
45604561
foreach ($results as $i=>$result) {
45614562
if ($result instanceof \Throwable) {
4562-
$document[$i] = ErrorDocument::fromException($result);
4563+
$documents[$i] = null;
4564+
$errors[$i] = ErrorDocument::fromException($result);
45634565
$success = false;
45644566
} else {
4565-
$document[$i] = $result;
4567+
$documents[$i] = $result;
4568+
$errors[$i] = new ErrorDocument(new ErrorCode(0),'',null);
45664569
}
45674570
}
45684571
$status = $success ? ResponseFactory::OK : ResponseFactory::FAILED_DEPENDENCY;
4572+
$document = $success ? $documents : $errors;
45694573
$response = ResponseFactory::fromObject($status, $document);
45704574
foreach ($results as $i=>$result) {
45714575
if ($result instanceof \Throwable) {
@@ -9886,7 +9890,7 @@ public function serialize()
98869890

98879891
public function jsonSerialize()
98889892
{
9889-
return array_filter($this->serialize());
9893+
return array_filter($this->serialize(), function($v) {return $v!==null;});
98909894
}
98919895

98929896
public static function fromException(\Throwable $exception)
@@ -10062,7 +10066,7 @@ class ErrorCode
1006210066
const PASSWORD_TOO_SHORT = 1021;
1006310067

1006410068
private $values = [
10065-
9999 => ["%s", ResponseFactory::INTERNAL_SERVER_ERROR],
10069+
0000 => ["Success", ResponseFactory::OK],
1006610070
1000 => ["Route '%s' not found", ResponseFactory::NOT_FOUND],
1006710071
1001 => ["Table '%s' not found", ResponseFactory::NOT_FOUND],
1006810072
1002 => ["Argument count mismatch in '%s'", ResponseFactory::UNPROCESSABLE_ENTITY],
@@ -10085,6 +10089,7 @@ class ErrorCode
1008510089
1019 => ["Pagination forbidden", ResponseFactory::FORBIDDEN],
1008610090
1020 => ["User '%s' already exists", ResponseFactory::CONFLICT],
1008710091
1021 => ["Password too short (<%d characters)", ResponseFactory::UNPROCESSABLE_ENTITY],
10092+
9999 => ["%s", ResponseFactory::INTERNAL_SERVER_ERROR],
1008810093
];
1008910094

1009010095
public function __construct(int $code)

0 commit comments

Comments
 (0)