![]() |
Controller created on image not found - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Controller created on image not found (/showthread.php?tid=49356) |
Controller created on image not found - El Forum - 02-16-2012 [eluser]Unknown[/eluser] Hello, Today I found a "bug" in my application that took me a couple of hours to figure out. I finally found the source of the problem, but it has confused me more than anything else. So, to situate the context, in my application I want to do some actions to the user's session everytime the page is reloaded. To do that, on the constructor of the session object, I check if it's an Ajax request (with the input->is_ajax_request() function) and if that's the case, I skip the pertinent actions. Now, that seemed to work fine until the bug I mentioned appeared. Turns out that when a resource is missing from the page (an image in my case), codeigniter calls the 404 error page. I'm not even sure where or when, because it's not an Ajax request and the error page is not displayed anywhere. I know all this can sound confusing, but I don't understand what is really going on. To test the problem, this are the changes I've made (to a clean CI 2.1.0 version). The bug doesn't appear if any of those is missing: - Add a controller to override the 404 error page, I added this one: Code: // add application/controllers/Errors.php - Use a controller that isn't the default one with an unexisting image, I used this: Code: // add application/controllers/Foo.php - I couldn't figure out another way of debugging it, so I created a log to write the events: Code: // add on CodeIgniter.php line 356 And that's all, the results on the log when visiting (in my case) http://localhost/Test/index.php/Foo are: Quote:Calling method Foo/index with request /test/index.php/Foo So, I don't know if this is a bug, but for me it's tottally unexpected that a controller is created when an image is not found. Controller created on image not found - El Forum - 02-16-2012 [eluser]InsiteFX[/eluser] Try this .htaccess Code: RewriteCond $1 !^(index\.php|assets|css|js|images|img|robots\.txt|favicon\.ico) Controller created on image not found - El Forum - 02-17-2012 [eluser]Unknown[/eluser] [quote author="InsiteFX" date="1329434055"]Try this .htaccess Code: RewriteCond $1 !^(index\.php|assets|css|js|images|img|robots\.txt|favicon\.ico) That gives me the same output, I still can't figure out what's happening. |