954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Incorrect page content passed to WordPress plugin in firefox

I originally posted this over on the WordPress forums , and got no responses. Eventually I figured out what the problem was and fixed it, but thought I'd repost here in case anyone else is experiencing similar issues (I couldn't find any related articles in my initial search on the symptoms.)

My experience was during development of a WordPress plugin, but I can see the potential for this to affect any web development on pages containing relative links. I hope someone finds this helpful.

/H

I have an interesting issue here. For some reason, in FireFox only, the page content being passed to my WordPress plugin is not correct for the page being viewed. It seems to be passing the content for the next page in the list, or something similar. The correct page content is actually presented in the browser, but not passed into the plugin, which is causing processing logic to fail in this browser.

This occurs on all pages in the site, regardless if I have placed any custom code or reference to the plugin into the page. I have been testing for days trying to figure out what/where the problem is occurring. All other browsers appear to work fine, but FireFox (and I have tested basically every version currently available to download). I don't believe it is a caching issue, as we've tried clearing, refreshing, changing/not using proxies, different computers, etc.

I have also noticed that the PHP $_POST and $_REQUEST variables don't appear to be populating in FireFox, however the program is still able to process data, so it must be receiving the post data somehow.

Has anyone else experienced anything like this? or have any suggestions that I could try?

I am open to basically any ideas at this point, and your help would be greatly appreciated.


Solution:after a couple days more testing and placing debug print statements throughout the core code, I managed to track down the cause of this problem. I will document it here for others who may be interested or experiencing similar symptoms as google yielded no helpful results.

FireFox implements a prefetch feature that is not present in other browsers. This creates an additional HTTP request on the server, which was triggering my custom code (as it should, but not as I expected). Basically the second page request was causing my plugins session to reset itself, and preventing the plugin code from executing as normal.

The workaround solution I found is to check for the presence of a $_SERVER['HTTP_X_MOZ'] variable, which is only sent in the prefetch request, on the initial call to my plugin. If this variable is set, simply exit and don't execute any of the plugin code.

Another possible solution would be to prevent WordPress (or the template) from including the link rel="next" or other tags that FireFox uses to trigger the prefetch, but this may not be ideal if such links are used for other purposes in the page.

Hopefully this will help someone else, as I found this issue to be a source of extreme frustration.

Hearth
Posting Whiz in Training
224 posts since Apr 2008
Reputation Points: 106
Solved Threads: 34
 

It seems this happens if the resource given sends an header with prefetch or next, just like you wrote:

- http://support.mozilla.com/en-US/kb/Firefox%20makes%20unrequested%20connections#w_link-prefetching
- https://developer.mozilla.org/En/Link_prefetching_FAQ

bye

cereal
Master Poster
709 posts since Aug 2007
Reputation Points: 214
Solved Threads: 120
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: