D

\XF\Mvc\Entity\Entity::saveIfChanged does not reset _writePending

  • Thread starter Thread starter DragonByte Tech
  • Start date Start date

Visitor Greeting

Welcome to NullWarehouse.com... We are currently seeking Mod's and Contributors. If you wish to apply for a Mod position then please click on Members dropdown arrow, then click on Staff App and fill it out completely and submit it. If you want to be a Contributor then start contributing and we will have our eye on you and take notice, something great could come of it.

  • We have redone the forum. If you notice any issues or errors please open a Support Ticket under the Members dropdown and let us know.
D

DragonByte Tech

Guest

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...
 
Back
Top Bottom