Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

CI_Controller should get loaded before any show_404() call #132

Closed
bitbucket-import opened this Issue · 6 comments

5 participants

@bitbucket-import

I wanted to write my own MY_Exceptions class which should mail me show_404() calls that indicate a broken link. To make the mailing a bit convenient, I tried to pull in the email helper, which faild because the get_instance() function resulted in the following error: "Class 'CI_Controller' not found".
After some research I found the reason for this: show_404() is called in the CI_Router::_validate_request() method which is called from the CI_Router::_set_routing() method which in turn is called in the CodeIgniter script BEFORE the CI_Controller class is loaded.

Wouldn't it be better to have access to CI_Controller in any show_404() calls, or am I 'missusing' the Exceptions overwrite.

@splitfeed

I'm trying to do the exact same thing, mailing from MY_Exceptions. Is there a better way to do this or is this something that might get fixed?

@kuboslav

Wouldn't be better write error controller and configure that to serve 404?

@splitfeed

What I'm trying to do is a drop in lib to report errors to devs/admins and not change the actual pages being served, otherwise that would have been a great idea

@narfbg
Owner

The Router class determines which controller should be called, so there's no logical reason to try to load anything controller-related prior to it.

@narfbg narfbg closed this
@dchill42

You might get your wish from #1818. If adopted, it will let you configure a 404 override that loads and calls a Controller method for a 404 error, letting you do whatever you want with the error - including sending an email.

@narfbg
Owner

There already is a possiblity to override 404 error pages via a controller, but apparently - that's not what they want to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.