Question

Something very weird is going on in a website I've made with CakePHP 1.3.10, and I don't know if it's a CakePHP problem or a PHP problem. The problem I have is with an action inside a controller that belongs to a plugin.

It's a simple function, it looks like:

function my_function($my_parameter) {

    $current_url = $this->params['url']['url']; //We get the current url (includes plugin/controller/action/parameters) from Cake's $this->params array

    $this->saveInfoToDB($current_url); //Function that saves the variable and other info to a table in the database - This function doesn't change the value of the variable, just saves it
}

This action is called by several links in the website, with the format '/my_plugin/my_controller/my_function/my_paramenter'. The idea is to show the page "my_function" and to store the current url in the database

So what is the problem? Let me explain:

Looking at the registries stored by the "saveInfoToDB" in the database, I'm realizing that the field where I store the value of "current_url" sometimes (it seems to be randomly) has unexpected values.

The normal values look like: /my_plugin/my_controller/my_function/3 (the integer goes from 1 to 100) The wrong values always look the same: /my_plugin/my_controller/my_function/js/iepngfix.htc

You can see what the problem is right? I don't know why in the world the js/iepngfix.htc is stored there!!! The reason I've put $my_parameter in the example is because I've realized that js/iepngfix.htc is pased as a parameter in that function (so it also shows in the $this->params array). But why?

There is no link in my website like /my_plugin/my_controller/my_function/js/iepngfix.htc, so how can this happen? I don't believe that many different users would just agree to enter that url in the browser (by the way, users must be logged in to access that link). Clearly, at some point that link is "called" when users browse the website, but I have no idea how...

This website used some of the IE hacks for PNG images (like the iepngfix.htc, iepng_tilebg.js, etc), but I've already removed them so they're not called anywhere, and even removed the files from the server.

I know it's difficult to get an answer to why is this happening, but if someone could give me some advice on how to troubleshoot my website to find the origin of the problem. I've tried to recreate this problem but I was able just once, using IE and accessing one of the links that users visit (for example /my_plugin/my_controller/my_function/43), but tried more times and it didn't happen again. So is this a problem with IE? Is this browser calling that link (the wrong one) when users call the right one?

Any help would be much appreciated!!

Was it helpful?

Solution

You're probably trying to include the iepngfix.htc behavior via a relative URL; maybe from within a stylesheet;

For example: if the iepngfix.htc is linked using this URL

../js/iepngfix.htc

And you're currently at this page:

http://example.com/mycontroller/myaction/

Then the iepngfix.htc URL is resolved as:

http://example.com/mycontroller/js/iepngfix.htc

Which will give a error 404.

However if you're currently at this page:

http://example.com/mycontroller/myaction/123

Then the iepngfix.htc URL is resolved as:

http://example.com/mycontroller/myaction/js/iepngfix.htc

The last part will be send to your controller-action as parameter (js/iepngfix.ht)

How to fix this

  • First of all, do you really need the pngfix? You probably only need it for Internet Explorer 6 and below. Unless you're targeting China, Internet Explorer 6 has a market share less than 1% (http://www.ie6countdown.com/). And even then, this behavior has a lot of negative side effects causing very poor performance
  • Check your URLs! Because of URL-rewriting, you should always use full paths to your 'assets' (CSS, JavaScript); i.e. /js/myscript.js in stead of js/myscript.js or ../js/myscript.js

OTHER TIPS

I think I might have found the culprit. There was this css code "hidden" in one of the css files:

body { behavior: url('js/iepngfix.htc') }

(I'll mention that the design was made by someone else)

After removing that fragment it seems that the issue is not happening again. Why? I don't know... Why was that passed as parameter in a function? I don't really know... Why did it happen randomly? I don't really know...

I'm sure there's an explanation for all those, but I don't have much time to investigate it further, I'm happy it's working now!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top