PHP on T R A X
Rapid Application Development Made Easy

Ticket #105: protect_filters.diff

File protect_filters.diff, 1.3 kB (added by zynode@zhuoqe.org, 2 years ago)

Protects before/after filters from being executed as controller actions

  • trax/vendor/trax/action_controller.php

    old new  
    650650                # Call the controller method based on the URL 
    651651                if($this->controller_object->execute_before_filters()) { 
    652652                    
    653                     if(method_exists($this->controller_object, $this->action)) { 
     653                    if(method_exists($this->controller_object, $this->action) && !$this->controller_object->my_is_filter($this->action)) { 
    654654                        //error_log('method '.$this->action.' exists, calling it'); 
    655655                        $action = $this->action; 
    656656                        //error_log('calling action routine ' 
     
    784784        } 
    785785    } 
    786786 
     787 
    787788    /** 
     789     *  Check if specific method is a filter 
     790     *  @uses $before_filters 
     791     *  @uses $after_filters 
     792     */ 
     793    function my_is_filter($method) { 
     794        $before = array_search($method, $this->before_filters); 
     795        $after = array_search($method, $this->after_filters); 
     796        return ($before === false && $after === false) ? false : true ; 
     797    } 
     798 
     799    /** 
    788800     *  Execute the before filters 
    789801     *  @uses $before_filters 
    790802     */