Carbon conflicts with older plugin versions

I’m using Shield on all my sites and on one of them I am getting php error messages every night.

PHP Fatal error: Uncaught Error: Call to undefined method Carbon\Carbon::startOfHour() in /home/xxxxxx/public_html/wp-content/plugins/wp-simple-firewall/src/lib/src/Modules/Events/Consolidate/ConsolidateAllEvents.php:34

On the WP support forum @Paul has told me this is probably caused by another plugin that’s also using the same Carbon library, but it’s stuck in an older version. In fact, I am using Simple Calendar plugin on this site and it also uses the Carbon library; it hasn’t been updated for 9 months, so would certainly be using an older version.

I have zero idea what the Carbon library does, but it does make me wonder whether this will be a growing headache for us. If we stick with some older versions of plugins and they start to conflict with other more recent plugins, isn’t that going to cause trouble?

This can happen also in WP when using plugin/themes that get very few updates with long periods of time passing between updates. The “if it ain’t broken don’t fix it” is a bad motto. But some dev adopt it and that way they forget to update support for libraries and properly maintain.
Fact is, for us this is a true issue, when plugins supporting WP 4.9 do not get proper attention.
We can’t fork Al of them or release our own yet. We don’t have the manpower.
We can do our best and start supplying the basics.
And let people see that in time we will get there.
In the short run this means slower growth, but it’s better to grow slow and steady, then to burst out and then stop.

1 Like

That’s a perennial problem unfortunately, not unique to ClassicPress. As plugins get abandoned, there’s an increasing chance they may start causing problems.

I’ve just taken over a WordPress site that was waaay out of date with some plugins that hadn’t been updated for 6 years. It was throwing all kinds of errors. In the end, I spent hours modifying each plugin just to get rid of the errors.

In Simple Calendar, it looks like there’s only a few files from the Carbon library in vendor\nesbot\carbon\src so it might be worth taking a backup of that folder and replacing the contents with the relevant files from https://github.com/briannesbitt/Carbon.

2 Likes

Yep, this is unfortunately a difficult scenario to avoid altogether. As @1stepforward suggest, the simplest approach for now is to replace out the libraries you need to as-and-when it crops up.

In this particular case, assuming you’ve done the backup etc., copy the contents
from /wp-simple-firewall/src/lib/vendor/nesbot/carbon/src
to /simple-calendar/vendor/nesbot/carbon/src

1 Like

This will work as long as there haven’t been any backwards-incompatible changes to the Carbon library in between these two versions. Generally not an easy thing to verify.

Great!. Thanks Paul. I’ll give that a try and report back. The calendar plugin does a nice job and I’m not keen to give up on it.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.