Closed MGatner closed 2 years ago
The code in Steps to Reproduce runs without errors. So I can't write test code, but the fix is the following:
--- a/src/Models/UserModel.php
+++ b/src/Models/UserModel.php
@@ -253,6 +253,10 @@ public function update($id = null, $data = null): bool
/** @throws DataException */
$result = parent::update($id, $data);
} catch (DataException $e) {
+ if ($this->tempUser === null) {
+ return true;
+ }
+
$messages = [
lang('Database.emptyDataset', ['update']),
];
PHP Version
8.1.2
CodeIgniter4 Version
4.2.7
Shield Version
develop
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
MySQL 8
Did you customize Shield?
No
What happened?
Calling
model(UserModel::class)->save()
with aarray
representing an existing user causes$tempUser
to benull
: https://github.com/codeigniter4/shield/blob/f4cdfb672b600a032a6f0bfc0b7735411bee0cae/src/Models/UserModel.php#L250Which makes the call to
saveEmailIdentity()
fail: https://github.com/codeigniter4/shield/blob/f4cdfb672b600a032a6f0bfc0b7735411bee0cae/src/Models/UserModel.php#L261Steps to Reproduce
This is obviously contrived but should cause the error:
Expected Output
No exception
Anything else?
Trace: