Skip to content

Installing Comet Cache on site with PHP < 5.3 causes fatal error #784

Description

@raamdev

PHP 5.3 is the version where the __DIR__ magic constant was introduced. The comet-cache.php file, which is the very first thing loaded when you install Comet Cache, loads the plugin.php, but it does so using a magic constant to figure out the full path to that file:

require_once __DIR__.'/plugin.php';

While Comet Cache requires PHP 5.4+ and there's a version check that prevents Comet Cache from crashing when you're running something older than PHP 5.4, that version check happens inside plugin.php, which is too late to catch the fact that the __DIR__ magic constant might cause a fatal error if you try installing on something older than PHP 5.3.

A review of plugin.php reveals also reveals that it would cause fatal errors on a site running PHP < 5.3, as there are many uses of __DIR__ in there.

I suggest that we make comet-cache.php and plugin.php as backwards compatible as possible. It would be a lot more desirable to show a proper "Requires PHP 5.4+" message than to generate a fatal error. Any uses of __DIR__ can be replaced with dirname(__FILE__), which should work back to PHP 5.0.


Reported here: https://wordpress.org/support/topic/error-when-enabling-plugin-1?replies=5#post-8501791

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions