aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2025-04-08 11:38:25 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-04-08 11:17:10 +0000
commit23a61a2b42ce9b48ced31d05dba3dff281d37cf7 (patch)
tree872f3d0ab4927dde0c2ec4bdf242b4e5742defcb
parent98b3a2ea61c1ac1c85db54d73db9d5611f4ab377 (diff)
downloadnextcloud-server-backport/52035/stable31.tar.gz
nextcloud-server-backport/52035/stable31.zip
refactor(RichObjectStrings): Only log error if key or value is not string in validatorbackport/52035/stable31
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--lib/private/RichObjectStrings/Validator.php6
-rw-r--r--tests/lib/RichObjectStrings/ValidatorTest.php5
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/private/RichObjectStrings/Validator.php b/lib/private/RichObjectStrings/Validator.php
index adc4a8710f7..d7f824f2948 100644
--- a/lib/private/RichObjectStrings/Validator.php
+++ b/lib/private/RichObjectStrings/Validator.php
@@ -10,6 +10,8 @@ namespace OC\RichObjectStrings;
use OCP\RichObjectStrings\Definitions;
use OCP\RichObjectStrings\InvalidObjectExeption;
use OCP\RichObjectStrings\IValidator;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
/**
* Class Validator
@@ -79,10 +81,10 @@ class Validator implements IValidator {
foreach ($parameter as $key => $value) {
if (!is_string($key)) {
- throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string');
+ Server::get(LoggerInterface::class)->error('Object for placeholder ' . $placeholder . ' is invalid, key ' . $key . ' is not a string');
}
if (!is_string($value)) {
- throw new InvalidObjectExeption('Object for placeholder ' . $placeholder . ' is invalid, value ' . $value . ' for key ' . $key . ' is not a string');
+ Server::get(LoggerInterface::class)->error('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 c5f88394a33..cbd54a0374c 100644
--- a/tests/lib/RichObjectStrings/ValidatorTest.php
+++ b/tests/lib/RichObjectStrings/ValidatorTest.php
@@ -10,7 +10,6 @@ namespace Test\RichObjectStrings;
use OC\RichObjectStrings\Validator;
use OCP\RichObjectStrings\Definitions;
-use OCP\RichObjectStrings\InvalidObjectExeption;
use Test\TestCase;
class ValidatorTest extends TestCase {
@@ -37,9 +36,6 @@ 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',
@@ -49,7 +45,6 @@ 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',