Compare commits

..

2 commits

View file

@ -2,6 +2,7 @@
namespace EesyPHP\Auth;
use EesyPHP\Hook;
use EesyPHP\Log;
use function EesyPHP\ensure_is_array;
use function EesyPHP\vardump;
@ -135,17 +136,24 @@ class User {
*/
public function save() {
if (!isset($this -> original_user)) {
Log::debug("%s->save(): no change to save", $this);
Log::debug("%s->save(): original_user not set, no change to save.", $this);
return true;
}
$changes = [];
foreach ($this->info as $attr => $value)
if ($this->original_user->$attr != $value)
$changes[$attr] = $value;
return call_user_func(
if (!$changes) {
Log::debug("%s->save(): no info updated, no change to save", $this);
return true;
}
$result = call_user_func(
array($this -> backend, 'update_user'),
$this -> original_user, $changes, true
);
if ($result)
Hook::trigger("user_updated", ["user" => $this, "changes" => $changes]);
return $result;
}
}