XF 2.2 extendClass was never called on Error

Dannymh

Active member
I have an addon that consists of a template, a template modification and 3 entitties. One of the entities is a user entity which extends the XF user entity.
This all works fine on my dev server, once I move it over and try to install it on the production server, it throws the following error '




Code:
An exception occurred: [LogicException] Tried to call XF\Extension::resolveExtendedClassToRoot on Onthebox\Ident\Entity\User, but extendClass was never called on the base class in src/XF/Extension.php on line 302

[LIST=1]
[*]XF\Extension->resolveExtendedClassToRoot() in src/XF/Mvc/Entity/Entity.php at line 103
[*]XF\Mvc\Entity\Entity->__construct() in src/XF/Mvc/Entity/Manager.php at line 743
[*]XF\Mvc\Entity\Manager->instantiateEntity() in src/XF/Mvc/Entity/Manager.php at line 564
[*]XF\Mvc\Entity\Manager->hydrateFromGrouped() in src/XF/Mvc/Entity/Finder.php at line 1404
[*]XF\Mvc\Entity\Finder->fetchOne() in src/XF/Mvc/Entity/Manager.php at line 151
[*]XF\Mvc\Entity\Manager->find() in src/XF/Repository/User.php at line 25
[*]XF\Repository\User->getVisitor() in src/XF/App.php at line 2054
[*]XF\App->getVisitorFromSession() in src/XF/Admin/App.php at line 68
[*]XF\Admin\App->start() in src/XF/App.php at line 2483
[*]XF\App->run() in src/XF.php at line 524
[*]XF::runApp() in admin.php at line 13
[/LIST]

The Entity for the USer looks like this

PHP:
namespace Onthebox\Ident\Entity;

use XF\Mvc\Entity\Structure;
class User extends \XF\Entity\User
{
    public static function getStructure(Structure $structure)
    {
        $structure = parent::getStructure($structure);
        $structure->relations['Ident'] = [
            'entity' => 'OntheBox\Ident:Status',
            'type' => self::TO_ONE,
            'conditions' => 'user_id',
            
        ];
        return $structure;
    }
}

Class Extension is:

Screen Shot 2023-11-29 at 9.14.36 pm.webp



What would cause it to throw this error?
Its taken the whole site down and I can't do anything but see that stack trace. Everything seems to be the same as how I normallly extend these
 
Code:
class User extends \XF\Entity\User

When you're extending classes you must use the "XenForo Class Proxy System". This is how we maintain a full inheritance chain which supports multiple add-ons extending the same class.

You should change your extended class to:

Code:
class User extends XFCP_User
 
Code:
class User extends \XF\Entity\User

When you're extending classes you must use the "XenForo Class Proxy System". This is how we maintain a full inheritance chain which supports multiple add-ons extending the same class.

You should change your extended class to:

Code:
class User extends XFCP_User
I copied the example from Kier's video of extending the user entity, in that he used
class User extends \XF\Entity\User and I had assumed it would be the same.

Let me give it a try and make sure
 
Code:
class User extends \XF\Entity\User

When you're extending classes you must use the "XenForo Class Proxy System". This is how we maintain a full inheritance chain which supports multiple add-ons extending the same class.

You should change your extended class to:

Code:
class User extends XFCP_User
I changed it to class User extends XFCP_User

Unfortuntely I get the same issue when I try to install it
 
What happens if you change it to : \XF\Entity\User
That's what it was previously when the issue started. I am going to move the file and class into the hierarchy structure

of OntheBox\Ident\XF\Entity

try and mirror the structure with XFCP and see if that helps

And the problem has been found, the issue was the namespace. When I moved it I realised there was a lowercase wehre there should be a cap, and correcting that resolved everything
 
Back
Top Bottom