"Cannot override final method" when no override is made
Hi all,
I have a class which extends my Controller class as follows:
PHP Code:
class ErrorsController extends Controller {
If, and only if I set the configuration variable "maintenance" to on (which triggers a fabricated 515 error) I get the fatal error:
Fatal error: Cannot override final method Controller::fireAction() in /Users/gid/Sites/bel/framework/controllers/ErrorsController.php on line 11
Line 11 is the class declaration...
If, however, another error is encountered, for example a 404 that fatal error does not occur.
Nowhere in my declaration of the ErrorsController class is there an override for the fireAction() method.
An ideas?
Last edited by blue-eye-labs; 10-26-2009 at 12:38 PM.
Reason: typo
Impossible to say without seeing the code, but I can only assume it as the message is saying - you define the method fireAction in your Controller class as final, and you are trying to also define a method fireAction in your ErrorController class. You really need to post the code though otherwise we only have the same error message as you to go on.
I could not find anything in the bugs.php.net database, so either you've found a new bug, my searches were not on the right keywords, or your code is, in fact, trying to re-define that final method. Without any more information, I have no way of knowing which of those 3 options is correct (or a 4th one I've not thought of). (I suppose a 4th option is that the wrong error message is being displayed for some other error.)
PS: If you want to post the actual code here, you might want to try to pare out as much code as possible and try to get it down the minimum amount of code needed to reproduce the error. That would serve 2 purposes: it might just show you where the problem is by limiting what you're looking at, and it will encourage the rest of us to spend time reading it. (I'm curious to find out what's going on, but I may not be curious enough to wade through a 1000 lines of code to find it. )
Last edited by NogDog; 10-26-2009 at 07:21 PM.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks for the responses. What's really weird about this is it doesn't happen every time ErrorsController is instantiated, but only with a specific error. I'll try and show loosely what is happening.
Which basically just calls the fireAction method of a specific controller. The line which reads if(Config::read("maintenance") == "true") { is where the maintenance status is checked and only when "maintenance" is "true" does the error occur. This causes a reroute via the httpError function which simply changes the route used to load the controller, loading the ErrorsController.
For the sake of the amount you'll have to read, I won't post the whole of ErrorsController here because it's got a lot of code which simply defines the different error messages to use in different situations (to make it friendly).
Can you post the Router::httpError() method please.
EDIT: This may sound stupid but it's caught me out a few times before - are you 100% sure the correct ErrorsController.php is being loaded? Is it possible you have an older version somewhere which may actually define a fireAction method on line 11?
public function httpError($err) {
$route = "/errors/index/" . $err . "/";
Router::reroute($route);
}
public function reroute($route) {
$_this =& Router::getInstance();
$_this->_clearRoutes();
$_GET['route'] = $route;
$_this->rerouted = true;
$_this->loadController();
}
I'm fairly sure that it is ErrorsController which is being loaded because I tried commenting out the entire class and all that happened is I got a blank screen (and no errors).
Bookmarks