colymba / silverstripe-restfulapi

SilverStripe RESTful API with a default JSON serializer.
BSD 3-Clause "New" or "Revised" License
64 stars 34 forks source link

Extension hooks get called twice #81

Open sanderha opened 7 years ago

sanderha commented 7 years ago

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

colymba commented 7 years ago

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