Lack of interest Add a _haveErrorsPreventSave() method in Entity

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

Sadik B

Well-known member
Prior to XenForo 2, in XenForo 1 DataWriter there was a method

PHP:
protected function _haveErrorsPreventSave()

This was extremely useful for an Addon Developer if you wanted to extend any DataWriter to do something just before something was saved. For example in the User DataWriter you could extend this method and you would then have to simply do the following,

PHP:
protected function _haveErrorsPreventSave()
{
    if (parent::_haveErrorsPreventSave())
    {
        return false;
    }

    $this->mycustomfunction();
}

This ensured that ALL error checking had passed before the DataWriter was saved and I could be certain to take my action knowing that the save() function will succeed.

In XenForo 2, there is no such _haveErrorsPreventSave() function. This means that we are forced to rely on preSave() or _preSave. Some error checking still happens AFTER preSave (for example in _fillDeferredValues) which means that I cannot be 100% certain that the Entity will pass _validateRequirements. So Either I have to do my action after entity save, which I cannot, OR I have do some of the XenForo validation myself.

If you simply added a function _haveErrorsPreventSave() in the Entity save() function right before you get the $db object ($db = $this->db()) for transaction, it will prove to be a 100% certain condition that $this->errors is empty and an addon can take some action knowing that the Entity WILL save.

Thanks
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Back
Top Bottom