XF 2.2 Cannot declare class ...because the name is already in use in src/XF/Extension.php at line 171

bzcomputers

Well-known member
I've got this error popping up on my Resource Manage pages after I recently updated an add-on...


The full error is: ErrorException: [E_WARNING] Cannot declare class Siropu\AdsManager\XFRM\Pub\Controller\XFCP_ResourceItem, because the name is already in use in src/XF/Extension.php at line 171.

Further looking into it the error and the XenForo file referenced src/XF/Extension.php at line 171. When going to that location, in extension.php, I do see notations in the XenForo file saying "// TODO: there may be a situation where this fails. If we've changed the extensions after classes have
// been loaded, it's possible these classes will already be loaded with a different config. Figure out
// how to handle that if possible. Remains to be seen if it comes up (mostly relating to add-on imports)."

I've had to completely disable my Resource Manager now (been over 2 weeks on a live site) since the error began occurring. Yes, I reported the issue to the add-on author and also opened a ticket with XenForo but at this point I haven't gotten any solutions or suggestions. Just putting this out there to get a few more eyes on it and see if someone else with a little more XenForo programming knowledge than me might be able to point me in the right direction to getting this fixed. Thanks.
 

bzcomputers

Well-known member
We're getting this error with multiple plugins now...
Was there ever a solution to this?
Yes. @Chris D found that when this error was showing up the add-on in question had duplicate class extensions. The duplicate extension tries to apply the same class a second time which is why you see the error.

The good thing is, it is a simple fix. You just delete the duplicate class extension(s) and rebuild the add-on. Do this by enabling "Development" mode and going to "Class Extensions" option and looking through the list. You should not see any duplicates of a class extension within the same add-on. If there is delete the duplicate(s) and then go to the add-on an select "rebuild".

class-extensons-1.jpg

class extensions-2.jpg class-extensons-3.jpg


The confusing part is he is not sure why it happened and sounded as if he may have not come across the issue before. This was just a couple days ago and now your're reporting the same issue so this issue may be becoming more prevalent.

The two add-ons that had duplicate extensions for me were:
Ads Manager 2
[cv6] NodeIcons

Not saying there is an issue with either add-on. It just might be a good idea for those of us that do come across this issue to keep track of the add-ons displaying this issue in case it is something that can be addressed from the add-on side itself. XenForo may also be able to implement a check for duplicate extensions if this becomes more wide spread.
 
Last edited:
Top