RSS Feed/News \XF\Mvc\Entity\Entity::saveIfChanged does not reset _writePending

Status
Not open for further replies.

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
24,631
Points
823

Reputation:

Problem: If you call $entity->preSave(), \XF\Mvc\Entity\Entity::$_writePending is set to true. If you subsequently call $entity->saveIfChanged(), and no changes are detected, you cannot write to the entity later, unless you manually call $entity->reset().

Proof of concept:
PHP:

Code:
$user = \XF::em()->find(\XF\Entity\User::class, 1);
$user->username = 'Admin'; // Set this to whatever the user name of userId 1 is

if (!$user->preSave())
{
    throw...

Read more

Continue reading...
 
Status
Not open for further replies.
Top