Commit 5b89765
committed
bug #1145 [Chat] Fix MongoDB identifier context in MessageNormalizer denormalize (camilleislasse)
This PR was merged into the main branch.
Discussion
----------
[Chat] Fix MongoDB identifier context in MessageNormalizer denormalize
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Docs? | no
| Issues | -
| License | MIT
The `MessageNormalizer::denormalize()` method was ignoring the `identifier` context option, always using hardcoded `'id'` key to restore the UUID.
This caused issues with MongoDB store which uses `_id` as the identifier (MongoDB's primary key convention). When saving messages, the store correctly passed `context: ['identifier' => '_id']` to `normalize()`, but `load()` called `denormalize()` without context, and even if it did, the method ignored it.
**Changes:**
- `MessageNormalizer::denormalize()` now uses `$context['identifier'] ?? 'id'` to read the UUID
- `MongoDb\MessageStore::load()` now passes the `identifier` context to `denormalize()`
- Fixed the MongoDB test to simulate real MongoDB behavior (data with `_id` key)
- Added test for custom identifier roundtrip
Commits
-------
b985024 [Chat] Fix MongoDB identifier context in MessageNormalizer denormalizeFile tree
4 files changed
+21
-3
lines changed- src/chat
- src
- Bridge/MongoDb
- tests
- Bridge/MongoDb
4 files changed
+21
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | | - | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
79 | 94 | | |
0 commit comments