8000 bug #46121 Fix "Notice: Undefined index: headers" in messenger with O… · symfony/symfony@5116846 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5116846

Browse files
bug #46121 Fix "Notice: Undefined index: headers" in messenger with Oracle (rjd22)
This PR was merged into the 4.4 branch. Discussion ---------- Fix "Notice: Undefined index: headers" in messenger with Oracle | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | no | License | MIT | Doc PR | no When using messenger with Oracle. The following exception happens: ``` In Connection.php line 453: [ErrorException] Notice: Undefined index: headers Exception trace: at /var/www/epmmusic/vendor/symfony/doctrine-messenger/Transport/Connection.php:453 Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection->decodeEnvelopeHeaders() ``` The reason for this exception is because most Oracle databases use all caps table and field names. This is not a problem for updating and saving but when messenger tries to get the messages it will result in a response with all caps field names. By selecting the was we do `SELECT table.foo as "foo"` we force the result to be lowercase even when the actual field is all caps. Commits ------- 3ae3e5a Fix "Notice: Undefined index: headers" in messenger with Oracle
2 parents 4e63f55 + 3ae3e5a commit 5116846

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Symfony/Component/Messenger/Tests/Transport/Doctrine/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function providePlatformSql(): iterable
409409

410410
yield 'Oracle' => [
411411
new OraclePlatform(),
412-
'SELECT w.* FROM messenger_messages w WHERE w.id IN(SELECT a.id FROM (SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
412+
'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN(SELECT a.id FROM (SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
413413
];
414414
}
415415
}

src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ public function get(): ?array
193193
$sql = str_replace('SELECT a.* FROM', 'SELECT a.id FROM', $sql);
194194

195195
$wrappedQuery = $this->driverConnection->createQueryBuilder()
196-
->select('w.*')
196+
->select(
197+
'w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", '.
198+
'w.created_at AS "created_at", w.available_at AS "available_at", '.
199+
'w.delivered_at AS "delivered_at"'
200+
)
197201
->from($this->configuration['table_name'], 'w')
198202
->where('w.id IN('.$sql.')');
199203

0 commit comments

Comments
 (0)
0