I’m having a really strange WordPress issue. Basically, I have a plugin file, and in that file it inserts a single row into the database. However, it’s being inserted twice for no reason what so every.
I’ve stripped back all the other lines in the file, so there’s only that single line, and still nothing. I’ve tried defining a variable, and if it’s equal to something, run the code and then change the variable. I’ve tried defining a function, and using function exists on it.
It’s still running the SQL twice. The timestamp in the table are either bang on the same, or 1 second apart, it’s very odd. I would understand if the file was being included twice, but it’s not otherwise I’d get PHP errors about functions already defined.
It’s not just SQL , I tested file_put_contents() to output some log, but it creates two files.
I EVEN used die(); after the file_put_contents() and it still saved two files.
I’ve disabled and deleted all other plugins, I’ve tried on 3 different themes and all the same outcome. I’ve tried on 2 different installs, localhost and server and still does the same.
Weird problem eh?
FURTHER UPDATE :
I’ve tested in different browsers, and it appears to be FireBug. I presume FireFox is calling the page once to get the content, and the FireBug is accessing the page right after as well. Pretty lame practice, and a pretty big bug to be honest.
At least I found the issue.
- Grew a moustache for the Envato Movember competition
- Community Moderator
- Contributed a Blog Post
- Author was Featured
- Item was Featured
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
Your page will load, then the browser will try to load the missing image, but because the image is missing it will load up your wordpress blog – which will load the plugin again. So your blog/plugin loads twice with every page load.
Fun bug! maybe that’s it.
No FireBug errors at all, it’s really odd.
I just tried it just on its own (without a WordPress install) and it doesn’t add it twice. It’s so weird because there’s nothing to explain why it’s doing it.
Cheers for your response, hopefully I can track down the exact reason.