240 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Has been part of the Envato Community for over 4 years
+2 more
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?

240 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Has been part of the Envato Community for over 4 years
+2 more
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.

3303 posts
  • Provided great contribution to our forums
  • Nominated Community Superstar of the month
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+18 more
dtbaker 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.

240 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Has been part of the Envato Community for over 4 years
+2 more
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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by