colymba/silverstripe-restfulapi

Extension hooks get called twice

Opened this issue · 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

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