230 posts
  • Has been a member for 4-5 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • United Kingdom
phpdude says

Hello,

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.

Any ideas?

230 posts
  • Has been a member for 4-5 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • United Kingdom
phpdude says

UPDATE :

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.

2821 posts
  • Australia
  • Community Moderator
  • Elite Author
  • Author had a Free File of the Month
  • Most Wanted Bounty Winner
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Contributed a Blog Post
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+10 more
dtbaker Volunteer moderator says

It could be a missing file. Check firebug for any 404 errors. eg: an image or javascript file that doesn’t exist, but is referenced in the html.

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.

230 posts
  • Has been a member for 4-5 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • United Kingdom
phpdude says

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.

by
by
by
by
by
by