rosell-dk / webp-express

Wordpress plugin for serving autogenerated WebP images instead of jpeg/png to browsers that supports WebP
GNU General Public License v3.0
226 stars 64 forks source link

Prevent problems if plugin is being included twice #472

Closed rosell-dk closed 3 years ago

rosell-dk commented 3 years ago

In #463, someone reported a notice about WEBPEXPRESS_MIGRATION_VERSION being already defined. I could not trace the reason that this happened and simply changed the line to:

if (!defined('WEBPEXPRESS_MIGRATION_VERSION')) {
   define('WEBPEXPRESS_MIGRATION_VERSION', '13');
}

I however just dug into how this could happen. The only way this can happen seems to be if the main plugin file (webp-express.php) gets included twice.

It surprises me that this can happen. Perhaps on a cron or something?

The question now is: Should we let webp-express run twice? Whatever mechanism that did this probably did it for a reason. I'd like to find out how it can happen, but I don't see it happening in my setups. So, I'm in the dark here.

But thinking about it: Would there ever be a good reason to add all the hooks twice? I cannot come up with any. But I can come up with plenty of problems in doing so. So... Lets exit if called twice.