PHP on T R A X
Rapid Application Development Made Easy

Ticket #105: protect_methods.diff

File protect_methods.diff, 1.2 kB (added by jimeh, 2 years ago)

Protects before/after filters and parent class methods 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                        #Get PUBLIC methods from controller object 
     654                        $all_methods = get_class_methods($this->controller_object);  
     655 
     656                        # Get Inherited methods from active_controller  
     657                        $inherited_methods = array_merge( 
     658                            get_class_methods(__CLASS__), 
     659                            $this->controller_object->before_filters, 
     660                            $this->controller_object->after_filters 
     661                        ); 
     662 
     663                        # Get non-inherited methods  
     664                        $action_methods = array_diff($all_methods, $inherited_methods); 
     665 
     666                        if(in_array($this->action, $action_methods)) { 
    654667                        //error_log('method '.$this->action.' exists, calling it'); 
    655668                        $action = $this->action; 
    656669                        //error_log('calling action routine '