Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 832
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 839
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5e5bb75..b4209f0e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [4.1.4] - 2025-09-26
+### Fixed
+* Fixed #657 Param `$len` should not be implicitly nullable. @danielmorell #658
+* Fixed Body serialization should respect `max_nesting_depth` config. @AronNovak #661
+
## [4.1.3] - 2025-04-17
### Fixed
* Fixed new 96 character access token fails validation. @danielmorell #654.
diff --git a/src/DataBuilder.php b/src/DataBuilder.php
index ea1c4145..cc71cf75 100644
--- a/src/DataBuilder.php
+++ b/src/DataBuilder.php
@@ -59,6 +59,8 @@ class DataBuilder implements DataBuilderInterface
protected $captureEmail;
protected $captureUsername;
+ protected $maxNestingDepth;
+
/**
* @var Utilities
*/
@@ -99,6 +101,7 @@ public function __construct(array $config)
$this->setCustom($config);
$this->setFingerprint($config);
$this->setTitle($config);
+ $this->setMaxNestingDepth($config);
$this->setNotifier($config);
$this->setBaseException($config);
$this->setIncludeCodeContext($config);
@@ -129,6 +132,12 @@ protected function setCaptureUsername($config)
$fromConfig = $config['capture_username'] ?? null;
$this->captureUsername = self::$defaults->captureUsername($fromConfig);
}
+
+ protected function setMaxNestingDepth($config)
+ {
+ $fromConfig = $config['max_nesting_depth'] ?? null;
+ $this->maxNestingDepth = self::$defaults->maxNestingDepth($fromConfig);
+ }
protected function setEnvironment($config)
{
@@ -411,7 +420,7 @@ protected function getBody(Throwable|string|Stringable $toLog, array $context):
} else {
$content = $this->getMessage($toLog);
}
- return new Body($content, $context, $this->getTelemetry());
+ return new Body($content, $context, $this->getTelemetry(), $this->maxNestingDepth);
}
public function getErrorTrace(ErrorWrapper $error)
diff --git a/src/Payload/Body.php b/src/Payload/Body.php
index 6b870cee..424ed257 100644
--- a/src/Payload/Body.php
+++ b/src/Payload/Body.php
@@ -23,7 +23,8 @@ class Body implements SerializerInterface
public function __construct(
private ContentInterface $value,
private array $extra = [],
- private ?array $telemetry = null
+ private ?array $telemetry = null,
+ private int $maxDepth = -1
) {
}
@@ -122,6 +123,10 @@ public function serialize()
$result['telemetry'] = $this->telemetry;
}
- return $this->utilities()->serializeForRollbarInternal($result, array('extra'));
+ if ($this->maxDepth === -1) {
+ return $this->utilities()->serializeForRollbarInternal($result, array('extra'));
+ }
+ $objectHashes = array();
+ return $this->utilities()->serializeForRollbar($result, array('extra'), $objectHashes, $this->maxDepth);
}
}
diff --git a/src/Payload/Notifier.php b/src/Payload/Notifier.php
index 8058cf3c..167a4092 100644
--- a/src/Payload/Notifier.php
+++ b/src/Payload/Notifier.php
@@ -8,7 +8,7 @@
class Notifier implements SerializerInterface
{
const NAME = "rollbar-php";
- const VERSION = "4.1.3";
+ const VERSION = "4.1.4";
use UtilitiesTrait;
diff --git a/src/Utilities.php b/src/Utilities.php
index c5cd9975..2e8aa39e 100644
--- a/src/Utilities.php
+++ b/src/Utilities.php
@@ -29,7 +29,7 @@ public static function isWindows()
public static function validateString(
mixed $input,
string $name = "?",
- int|array $len = null,
+ int|array|null $len = null,
bool $allowNull = true
): void {
if (is_null($input)) {
diff --git a/tests/BodyTest.php b/tests/BodyTest.php
index 16251625..27f28794 100644
--- a/tests/BodyTest.php
+++ b/tests/BodyTest.php
@@ -46,4 +46,37 @@ public function testSerialize(): void
$encoded
);
}
+
+ public function testSerializeWithMaxNestingDepth(): void
+ {
+ $value = m::mock(ContentInterface::class)
+ ->shouldReceive("serialize")
+ ->andReturn("{CONTENT}")
+ ->shouldReceive("getKey")
+ ->andReturn("content_interface")
+ ->mock();
+
+ // Create deeply nested array that would cause memory issues
+ $deepArray = array('level1' => array('level2' => array('level3' => array('level4' => 'deep_value'))));
+
+ // Test without depth limit - should serialize completely
+ $bodyNoLimit = new Body($value, array('deep' => $deepArray), null, -1);
+ $resultNoLimit = $bodyNoLimit->serialize();
+
+ // Test with depth limit - should truncate deep nesting
+ $bodyWithLimit = new Body($value, array('deep' => $deepArray), null, 2);
+ $resultWithLimit = $bodyWithLimit->serialize();
+
+ // Verify basic structure exists
+ $this->assertArrayHasKey('extra', $resultNoLimit);
+ $this->assertArrayHasKey('extra', $resultWithLimit);
+
+ // Without limit should have all nested levels
+ $this->assertEquals('deep_value', $resultNoLimit['extra']['deep']['level1']['level2']['level3']['level4']);
+
+ // With limit should truncate the 'deep' array due to depth constraint
+ // At depth 2: root -> extra -> deep (gets truncated to empty array)
+ $this->assertArrayHasKey('deep', $resultWithLimit['extra']);
+ $this->assertEmpty($resultWithLimit['extra']['deep']); // Truncated due to depth limit
+ }
}