File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
88* Rename queue option ` table ` to ` collection `
99* Replace queue option ` expire ` with ` retry_after `
1010
11+ ## [ 4.3.1]
12+
13+ * Fix memory leak when filling nested fields using dot notation by @GromNaN in [ #2962 ] ( https://github.com/mongodb/laravel-mongodb/pull/2962 )
14+
1115## [ 4.3.0] - 2024-04-26
1216
1317* New aggregation pipeline builder by @GromNaN in [ #2738 ] ( https://github.com/mongodb/laravel-mongodb/pull/2738 )
Original file line number Diff line number Diff line change 4646use function str_contains ;
4747use function str_starts_with ;
4848use function strcmp ;
49- use function uniqid ;
5049use function var_export ;
5150
5251/** @mixin Builder */
@@ -55,6 +54,8 @@ abstract class Model extends BaseModel
5554 use HybridRelations;
5655 use EmbedsRelations;
5756
57+ private const TEMPORARY_KEY = '__LARAVEL_TEMPORARY_KEY__ ' ;
58+
5859 /**
5960 * The collection associated with the model.
6061 *
@@ -271,12 +272,10 @@ public function setAttribute($key, $value)
271272 // Support keys in dot notation.
272273 if (str_contains ($ key , '. ' )) {
273274 // Store to a temporary key, then move data to the actual key
274- $ uniqueKey = uniqid ($ key );
275-
276- parent ::setAttribute ($ uniqueKey , $ value );
275+ parent ::setAttribute (self ::TEMPORARY_KEY , $ value );
277276
278- Arr::set ($ this ->attributes , $ key , $ this ->attributes [$ uniqueKey ] ?? null );
279- unset($ this ->attributes [$ uniqueKey ]);
277+ Arr::set ($ this ->attributes , $ key , $ this ->attributes [self :: TEMPORARY_KEY ] ?? null );
278+ unset($ this ->attributes [self :: TEMPORARY_KEY ]);
280279
281280 return $ this ;
282281 }
You can’t perform that action at this time.
0 commit comments