Welcome Guest, Not a member yet? Register   Sign In
Bizarre! - empty image causes reload of default controller

Hello, took me a while to track this down, was causing a very strange session problem.
If you have an image entry in a view with no parameter in it ie: <img src="">
it causes the default controller to be called after the run of your desired controller.
Debug looks like this:
//first controller run everything fine
DEBUG - 2010-09-08 18:14:47 --&gt; Final output sent to browser
DEBUG - 2010-09-08 18:14:47 --&gt; Total execution time: 0.1297
DEBUG - 2010-09-08 18:14:47 --&gt; Config Class Initialized
DEBUG - 2010-09-08 18:14:47 --&gt; Hooks Class Initialized
DEBUG - 2010-09-08 18:14:47 --&gt; URI Class Initialized
//here's where it finds the empty image tag and gets confused and runs another controller
DEBUG - 2010-09-08 18:14:47 --&gt; No URI present. Default controller set.
DEBUG - 2010-09-08 18:14:47 --&gt; Router Class Initialized
DEBUG - 2010-09-08 18:14:47 --&gt; Output Class Initialized
// continues to load up everything in the default controller - including changing session vars that should not be changed!

Just letting people know in case they see some strange happenings.

Not strange. Every image in your HTML page is another request to the server.

The requests hits your rewrite rules, which can't match any exclusion rule (since you are requesting an image without source, meaning the current URL), so it gets rewritten to index.php, causing a second request.

Code your output properly (empty image tags are an error that needs to be fixed). With most .htaccess examples posted here you will have the same problem if you try to load an image that doesn't exist.

Hi, yes I hear what you're saying and it makes sense. I agree that empty images are a no-no.
But, it's not just that the image doesn't exist (which outputs a 404 error silently). If you have for example img src="x", anything in the quotes - it will output the silent error. But if you have nothing in the quotes it will rerun the default controller - so that's 2 controllers for the same page request.
You're saying this is caused solely by the htaccess rewrite rules?

Theme © iAndrew 2016 - Forum software by © MyBB