silverstripe-restfulapi icon indicating copy to clipboard operation
silverstripe-restfulapi copied to clipboard

Extension hooks get called twice

Open sanderha opened this issue 6 years ago • 1 comments

It seems the various hooks in classes such as RESTfulAPI_DefaultQueryHandler get called twice.

If I define onAfterDeserialize() on a DataExtension, this method gets called twice in RESTfulAPI_DefaultQueryHandler::updateModel(), by this code:

        // After deserialize hook
        if (method_exists($model, 'onAfterDeserialize')) {
            $model->onAfterDeserialize($payload);
        }
        $model->extend('onAfterDeserialize', $payload);

It seems method_exists returns true in this case for some reason. Im running this on SilverStripe 3.5

sanderha avatar Aug 15 '17 11:08 sanderha

umm... probably should just keep the extend call and get rid of the other one. Care to send a PR?

colymba avatar Aug 17 '17 12:08 colymba