I was using PHP 7.0.4 and everything was running smoothly and I just upgraded to PHP 7.0.8 and I started getting errors like this one all over the place.
Fatal error: Cannot declare class Plugins\Users\Plugin because the name is already in use in /var/www/html/plugins/Users/Plugin.php on line 8
Does anyone have any idea whats going on, I've been reading through the change logs but that's a patch update it should not break anything?
Additionally, if no solution is found to this problem, how can I downgrade back to 7.0.4? (I'm using ubuntu 16.04 and I just upgraded to the point release)
To sum the comments so far:
require
or include
anywhereThere is not enough data to say definitively, however I suspect opcache. That error, in fact, originates in opcache so I suspect until this point the error had been hidden by one of several opcode bugs, probably #66773.
You legitimately have an autoloading issue that needs to be fixed. Rename the class, check your namespaces, and remove any hard requires.
You might be able to restore the former buggy behavior by disabling/re-enabling opcache or reverting to 7.0.4, but really the bug was only masked by a particular combination of autoloading and opcache. It was, indeed, only by chance that the issue went undetected until now and it'll be only by chance that you can mask it again.
So the best course is to fix the issue.
Well, apparently I was so blinded by the fact that the error started occurring after the upgrade, that I ignored it even though it was right before my eyes.
These are the first few lines of the class in question (and apparently a bunch of other classes):
<?php
namespace Plugins\Users;
use FW\Utility\Models\Plugins\Plugin;
class Plugin extends Plugin {
As you, and finally I, can clearly see, the class name Plugin
is ambiguous, but wasn't in 7.0.4, which is weird and is probably caused by the bug described in bishop's answer
Guess I should have listened to Machavity, huh.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With