Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Store/DoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ public function configureSchema(Schema $schema, Connection $connection): void
->setLength(255)
->setNotnull(true);
$table->addColumn('payload', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);
$table->addColumn('recorded_on', Types::DATETIMETZ_IMMUTABLE)
->setNotnull(true);
Expand All @@ -347,6 +348,7 @@ public function configureSchema(Schema $schema, Connection $connection): void
->setNotnull(true)
->setDefault(false);
$table->addColumn('custom_headers', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);

$table->setPrimaryKey(['id']);
Expand Down
2 changes: 2 additions & 0 deletions src/Store/StreamDoctrineDbalStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,15 @@ public function configureSchema(Schema $schema, Connection $connection): void
->setLength(255)
->setNotnull(true);
$table->addColumn('event_payload', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);
$table->addColumn('recorded_on', Types::DATETIMETZ_IMMUTABLE)
->setNotnull(true);
$table->addColumn('archived', Types::BOOLEAN)
->setNotnull(true)
->setDefault(false);
$table->addColumn('custom_headers', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);

$table->setPrimaryKey(['id']);
Expand Down
1 change: 1 addition & 0 deletions src/Subscription/Store/DoctrineSubscriptionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public function configureSchema(Schema $schema, Connection $connection): void
->setLength(32)
->setNotnull(false);
$table->addColumn('error_context', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(false);
$table->addColumn('retry_attempt', Types::INTEGER)
->setNotnull(true);
Expand Down
5 changes: 5 additions & 0 deletions src/Subscription/ThrowableToErrorContextTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use function is_resource;
use function mb_strlen;
use function mb_substr;
use function str_replace;

/**
* @psalm-import-type Context from SubscriptionError
Expand Down Expand Up @@ -70,6 +71,10 @@ private static function transformThrowable(Throwable $error): array
*/
private static function transformTrace(array $trace): array
{
if (array_key_exists('class', $trace)) {
$trace['class'] = str_replace("\x00", '', $trace['class']);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any better suggestions @DavidBadura ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be its own PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this is not doing any harm. When we adjust the table type to jsonb Postgres checks if the json is valid and doesn't like null bytes in there.

I don't think that this must be in a separate bugfix PR but I could extract it. The only thing is if the user already has null bytes in the table. Then he would need to remove them. Or do you have a case in mind?

}

if (!array_key_exists('args', $trace)) {
return $trace;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/Store/DoctrineDbalStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ public function testConfigureSchema(): void
->setLength(255)
->setNotnull(true);
$table->addColumn('payload', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);
$table->addColumn('recorded_on', Types::DATETIMETZ_IMMUTABLE)
->setNotnull(true);
Expand All @@ -1320,6 +1321,7 @@ public function testConfigureSchema(): void
->setNotnull(true)
->setDefault(false);
$table->addColumn('custom_headers', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);

$table->setPrimaryKey(['id']);
Expand Down Expand Up @@ -1362,6 +1364,7 @@ public function testConfigureSchemaWithStringAsAggregateIdType(): void
->setLength(255)
->setNotnull(true);
$table->addColumn('payload', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);
$table->addColumn('recorded_on', Types::DATETIMETZ_IMMUTABLE)
->setNotnull(true);
Expand All @@ -1372,6 +1375,7 @@ public function testConfigureSchemaWithStringAsAggregateIdType(): void
->setNotnull(true)
->setDefault(false);
$table->addColumn('custom_headers', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);

$table->setPrimaryKey(['id']);
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Store/StreamDoctrineDbalStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1416,13 +1416,15 @@ public function testConfigureSchema(): void
->setLength(255)
->setNotnull(true);
$table->addColumn('event_payload', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);
$table->addColumn('recorded_on', Types::DATETIMETZ_IMMUTABLE)
->setNotnull(true);
$table->addColumn('archived', Types::BOOLEAN)
->setNotnull(true)
->setDefault(false);
$table->addColumn('custom_headers', Types::JSON)
->setPlatformOption('jsonb', true)
->setNotnull(true);

$table->setPrimaryKey(['id']);
Expand Down
Loading