File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -225,12 +225,18 @@ public function activate(User $user): void
225225 */
226226 public function insert ($ data = null , bool $ returnID = true )
227227 {
228- $ this ->tempUser = $ data instanceof User ? $ data : null ;
228+ // Clone User object for not changing the passed object.
229+ $ this ->tempUser = $ data instanceof User ? clone $ data : null ;
229230
230231 $ result = parent ::insert ($ data , $ returnID );
231232
232233 $ this ->checkQueryReturn ($ result );
233234
235+ // Set user id to the passed User object.
236+ if ($ data instanceof User) {
237+ $ data ->id = $ this ->insertID ;
238+ }
239+
234240 return $ returnID ? $ this ->insertID : $ result ;
235241 }
236242
@@ -245,7 +251,8 @@ public function insert($data = null, bool $returnID = true)
245251 */
246252 public function update ($ id = null , $ data = null ): bool
247253 {
248- $ this ->tempUser = $ data instanceof User ? $ data : null ;
254+ // Clone User object for not changing the passed object.
255+ $ this ->tempUser = $ data instanceof User ? clone $ data : null ;
249256
250257 try {
251258 /** @throws DataException */
You can’t perform that action at this time.
0 commit comments