Skip to content

Commit 3808f86

Browse files
Merge pull request nextcloud#52062 from nextcloud/revert/52035
2 parents edeccc8 + 8358a7f commit 3808f86

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/private/RichObjectStrings/Validator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use OCP\RichObjectStrings\Definitions;
1111
use OCP\RichObjectStrings\InvalidObjectExeption;
1212
use OCP\RichObjectStrings\IValidator;
13-
use OCP\Server;
14-
use Psr\Log\LoggerInterface;
1513

1614
/**
1715
* Class Validator
@@ -81,10 +79,10 @@ protected function validateParameter(string $placeholder, array $parameter): voi
8179

8280
foreach ($parameter as $key => $value) {
8381
if (!is_string($key)) {
84-
Server::get(LoggerInterface::class)->error('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string');
82+
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string');
8583
}
8684
if (!is_string($value)) {
87-
Server::get(LoggerInterface::class)->error('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string');
85+
throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string');
8886
}
8987
}
9088
}

tests/lib/RichObjectStrings/ValidatorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OC\RichObjectStrings\Validator;
1212
use OCP\RichObjectStrings\Definitions;
13+
use OCP\RichObjectStrings\InvalidObjectExeption;
1314
use Test\TestCase;
1415

1516
class ValidatorTest extends TestCase {
@@ -36,6 +37,9 @@ public function testValidate(): void {
3637
]);
3738
$this->addToAssertionCount(2);
3839

40+
$this->expectException(InvalidObjectExeption::class);
41+
42+
$this->expectExceptionMessage('Object for placeholder string1 is invalid, value 123 for key key is not a string');
3943
$v->validate('test {string1} test.', [
4044
'string1' => [
4145
'type' => 'user',
@@ -45,6 +49,7 @@ public function testValidate(): void {
4549
],
4650
]);
4751

52+
$this->expectExceptionMessage('Object for placeholder string1 is invalid, key 456 is not a string');
4853
$v->validate('test {string1} test.', [
4954
'string1' => [
5055
'type' => 'user',

0 commit comments

Comments
 (0)