cakephp-filter-plugin icon indicating copy to clipboard operation
cakephp-filter-plugin copied to clipboard

Component doesn't check model behaviors' methods or mapped methods

Open curtisgibby opened this issue 11 years ago • 0 comments

In FilterComponent::beforeRender, when there's a selector specified, you check to see if a model has the specified method...

if (!method_exists($workingModel, $settings['selector']))
{
// trigger the error

... and if it doesn't, you trigger an error.

This doesn't take into account if the model has access to the selector method through a behavior, either explicitly declared in the behavior or through a magic "mapMethod." Adding a check against the model's BehaviorCollection->hasMethod resolves this problem.

if (
    ! method_exists($workingModel, $settings['selector']) &&
    ! $workingModel->Behaviors->hasMethod($settings['selector'])
)
{
// now you can trigger that error

curtisgibby avatar Nov 13 '14 22:11 curtisgibby