huge icon indicating copy to clipboard operation
huge copied to clipboard

[INFO] Why you should not name your controller "error" (incl. fix) :)

Open Vallevard opened this issue 8 years ago • 3 comments

Hello, It looks like when someone writes something like: http://localhost/huge/error , it's displayed this error : Fatal error: Cannot redeclare class ErrorController in (path) at line n. To fix this error, I think it's necessary to remove the lines 51 and 52 at application.php (core folder), because the ErrorController is already declared at line 38.

Regards.

Vallevard avatar Aug 24 '16 21:08 Vallevard

Thanks! But this is tricky, as it will be the same problem with every already used classname, similar things also appear in other older frameworks (unless you use namespaces). As this problem is more an edge case and this project itself is already EOL, I would simply rename the issue and keep it open, so people can find this workaround!

panique avatar Aug 24 '16 21:08 panique

you're right.

Thinking about the title :

Why you should not name your controller "error"

Whatever you want to call the controller for handling errors always you will have this error, at less before we call the error controller, it's checked if it's already declared, something like this.

if(!class_exists('ErrorController')){
       require Config::get('PATH_CONTROLLER') . 'ErrorController.php';
       $this->controller = new ErrorController;
  }
    $this->controller->error404();

Vallevard avatar Aug 24 '16 21:08 Vallevard

ups, I closed it.

Vallevard avatar Aug 24 '16 22:08 Vallevard