diff options
author | Joas Schilling <coding@schilljs.com> | 2025-04-09 08:29:43 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-04-09 08:29:43 +0200 |
commit | 8c460c9f582af2b46fd6236b36e091451d49bb2a (patch) | |
tree | e467ee2c26cc4a47d31a336e492588af3f97da33 | |
parent | 5ace494bf29b0ac9a18a4538578e2366972deaeb (diff) | |
download | nextcloud-server-revert/52038.tar.gz nextcloud-server-revert/52038.zip |
Revert "refactor(RichObjectStrings): Only log error if key or value is not string in validator"revert/52038
This reverts commit 23a61a2b42ce9b48ced31d05dba3dff281d37cf7.
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/RichObjectStrings/Validator.php | 6 | ||||
-rw-r--r-- | tests/lib/RichObjectStrings/ValidatorTest.php | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/RichObjectStrings/Validator.php b/lib/private/RichObjectStrings/Validator.php index d7f824f2948..adc4a8710f7 100644 --- a/lib/private/RichObjectStrings/Validator.php +++ b/lib/private/RichObjectStrings/Validator.php @@ -10,8 +10,6 @@ namespace OC\RichObjectStrings; use OCP\RichObjectStrings\Definitions; use OCP\RichObjectStrings\InvalidObjectExeption; use OCP\RichObjectStrings\IValidator; -use OCP\Server; -use Psr\Log\LoggerInterface; /** * Class Validator @@ -81,10 +79,10 @@ class Validator implements IValidator { foreach ($parameter as $key => $value) { if (!is_string($key)) { - Server::get(LoggerInterface::class)->error('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string'); + throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string'); } if (!is_string($value)) { - Server::get(LoggerInterface::class)->error('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string'); + throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string'); } } } diff --git a/tests/lib/RichObjectStrings/ValidatorTest.php b/tests/lib/RichObjectStrings/ValidatorTest.php index cbd54a0374c..c5f88394a33 100644 --- a/tests/lib/RichObjectStrings/ValidatorTest.php +++ b/tests/lib/RichObjectStrings/ValidatorTest.php @@ -10,6 +10,7 @@ namespace Test\RichObjectStrings; use OC\RichObjectStrings\Validator; use OCP\RichObjectStrings\Definitions; +use OCP\RichObjectStrings\InvalidObjectExeption; use Test\TestCase; class ValidatorTest extends TestCase { @@ -36,6 +37,9 @@ class ValidatorTest extends TestCase { ]); $this->addToAssertionCount(2); + $this->expectException(InvalidObjectExeption::class); + + $this->expectExceptionMessage('Object for placeholder string1 is invalid, value 123 for key key is not a string'); $v->validate('test {string1} test.', [ 'string1' => [ 'type' => 'user', @@ -45,6 +49,7 @@ class ValidatorTest extends TestCase { ], ]); + $this->expectExceptionMessage('Object for placeholder string1 is invalid, key 456 is not a string'); $v->validate('test {string1} test.', [ 'string1' => [ 'type' => 'user', |