diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3ff509ab0..88a771c63 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -200,11 +200,6 @@ parameters: count: 1 path: src/Options.php - - - message: "#^Method Sentry\\\\Options\\:\\:getMaxValueLength\\(\\) should return int but returns mixed\\.$#" - count: 1 - path: src/Options.php - - message: "#^Method Sentry\\\\Options\\:\\:getOrgId\\(\\) should return int\\|null but returns mixed\\.$#" count: 1 diff --git a/src/Options.php b/src/Options.php index 28093ed6e..f69ccf933 100644 --- a/src/Options.php +++ b/src/Options.php @@ -935,28 +935,6 @@ public function setDefaultIntegrations(bool $enable): self return $this; } - /** - * Gets the max length for values in the event payload. - */ - public function getMaxValueLength(): int - { - return $this->options['max_value_length']; - } - - /** - * Sets the max length for specific values in the event payload. - * - * @param int $maxValueLength The number of characters after which the values containing text will be truncated - */ - public function setMaxValueLength(int $maxValueLength): self - { - $options = array_merge($this->options, ['max_value_length' => $maxValueLength]); - - $this->options = $this->resolver->resolve($options); - - return $this; - } - /** * Gets the http proxy setting. */ @@ -1271,7 +1249,6 @@ private function configureOptions(OptionsResolver $resolver): void 'in_app_exclude' => [], 'in_app_include' => [], 'send_default_pii' => false, - 'max_value_length' => 1024, 'transport' => null, 'http_client' => null, 'http_proxy' => null, @@ -1320,7 +1297,6 @@ private function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('integrations', ['Sentry\\Integration\\IntegrationInterface[]', 'callable']); $resolver->setAllowedTypes('send_default_pii', 'bool'); $resolver->setAllowedTypes('default_integrations', 'bool'); - $resolver->setAllowedTypes('max_value_length', 'int'); $resolver->setAllowedTypes('transport', ['null', TransportInterface::class]); $resolver->setAllowedTypes('http_client', ['null', HttpClientInterface::class]); $resolver->setAllowedTypes('http_proxy', ['null', 'string']); diff --git a/src/Serializer/AbstractSerializer.php b/src/Serializer/AbstractSerializer.php index 42946bf8d..5f5b5e753 100644 --- a/src/Serializer/AbstractSerializer.php +++ b/src/Serializer/AbstractSerializer.php @@ -223,10 +223,6 @@ protected function serializeString(string $value): string $encoded = mb_convert_encoding($value, 'UTF-8') ?: ''; } - if (mb_strlen($encoded) > $this->options->getMaxValueLength()) { - $encoded = mb_substr($encoded, 0, $this->options->getMaxValueLength() - 10, 'UTF-8') . ' {clipped}'; - } - return $encoded; } diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php index 4bc7c7fa4..015818b79 100644 --- a/tests/OptionsTest.php +++ b/tests/OptionsTest.php @@ -320,13 +320,6 @@ static function (): void {}, 'setDefaultIntegrations', ]; - yield [ - 'max_value_length', - 50, - 'getMaxValueLength', - 'setMaxValueLength', - ]; - yield [ 'transport', new HttpTransport(new Options(), new HttpClient('foo', 'bar'), new PayloadSerializer(new Options())), diff --git a/tests/Serializer/AbstractSerializerTest.php b/tests/Serializer/AbstractSerializerTest.php index 36f753c73..752e7e44b 100644 --- a/tests/Serializer/AbstractSerializerTest.php +++ b/tests/Serializer/AbstractSerializerTest.php @@ -393,26 +393,6 @@ public function testBrokenEncoding(bool $serializeAllObjects): void } } - /** - * @dataProvider serializeAllObjectsDataProvider - */ - public function testLongString(bool $serializeAllObjects): void - { - $serializer = $this->createSerializer(); - - if ($serializeAllObjects) { - $serializer->setSerializeAllObjects(true); - } - - foreach ([100, 1000, 1010, 1024, 1050, 1100, 10000] as $length) { - $input = str_repeat('x', $length); - $result = $this->invokeSerialization($serializer, $input); - - $this->assertIsString($result); - $this->assertLessThanOrEqual(1024, \strlen($result)); - } - } - /** * @dataProvider serializeAllObjectsDataProvider */ diff --git a/tests/Serializer/SerializerTest.php b/tests/Serializer/SerializerTest.php index d402f210f..3833e5412 100644 --- a/tests/Serializer/SerializerTest.php +++ b/tests/Serializer/SerializerTest.php @@ -201,30 +201,6 @@ public function testSerializableObjectThatThrowsAnException(): void $this->assertEquals('Object ' . \get_class($object), $this->invokeSerialization($serializer, $object)); } - public function testLongStringWithOverwrittenMessageLength(): void - { - $serializer = $this->createSerializer(new Options(['max_value_length' => 500])); - - foreach ([100, 490, 499, 500, 501, 1000, 10000] as $length) { - $input = str_repeat('x', $length); - $result = $this->invokeSerialization($serializer, $input); - - $this->assertIsString($result); - $this->assertLessThanOrEqual(500, \strlen($result)); - } - } - - public function testClippingUTF8Characters(): void - { - $serializer = $this->createSerializer(new Options(['max_value_length' => 19])); - - $clipped = $this->invokeSerialization($serializer, 'Прекратите надеяться, что ваши пользователи будут сообщать об ошибках'); - - $this->assertSame('Прекратит {clipped}', $clipped); - $this->assertNotNull(json_encode($clipped)); - $this->assertSame(\JSON_ERROR_NONE, json_last_error()); - } - /** * @return Serializer */