Fixed Error when uninstalling add-on with custom node type

Jake B.

Well-known member
Affected version
2.0
If you have an add-on that creates custom node types and then uninstall that add-on, assuming the add-on doesn't remove all nodes with that custom type you'll get this error:

Code:
LogicException: Entity (class: ) could not be found in src/XF/Mvc/Entity/Manager.php at line 45

[LIST=1]
[*]XF\Mvc\Entity\Manager->getEntityClassName() in src/XF/Mvc/Entity/Manager.php at line 117
[*]XF\Mvc\Entity\Manager->find() in src/XF/Entity/Node.php at line 120
[*]XF\Entity\Node->getData() in src/XF/Mvc/Entity/Entity.php at line 139
[*]XF\Mvc\Entity\Entity->get() in src/XF/Mvc/Entity/Entity.php at line 92
[*]XF\Mvc\Entity\Entity->__get() in src/XF/Entity/Node.php at line 13
[*]XF\Entity\Node->canView() in src/XF/Mvc/Entity/AbstractCollection.php at line 298
[*]XF\Mvc\Entity\AbstractCollection->XF\Mvc\Entity\{closure}()
[*]array_filter() in src/XF/Mvc/Entity/AbstractCollection.php at line 167
[*]XF\Mvc\Entity\AbstractCollection->filter() in src/XF/Mvc/Entity/AbstractCollection.php at line 299
[*]XF\Mvc\Entity\AbstractCollection->filterViewable() in src/XF/Repository/Node.php at line 136
[*]XF\Repository\Node->filterViewable() in src/XF/Repository/Node.php at line 20
[*]XF\Repository\Node->getNodeList() in src/XF/Pub/Controller/Forum.php at line 50
[*]XF\Pub\Controller\Forum->actionList() in src/XF/Mvc/Dispatcher.php at line 232
[*]XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 85
[*]XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
[*]XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1645
[*]XF\App->run() in src/XF.php at line 329
[*]XF::runApp() in index.php at line 13
[/LIST]

Now, I realize I could just remove all nodes with that node_type_id but that seems like it could potentially be a bit too destructive if those nodes would contain content, so maybe it'd be a better to have the nodes be ignored if the add-on is uninstalled rather than attempting to load no entity :)
 
I've fixed this now, thanks. However, just to comment on something:

Now, I realize I could just remove all nodes with that node_type_id but that seems like it could potentially be a bit too destructive if those nodes would contain content
Add-on uninstallation is, by definition, destructive. All data created by the add-on is expected to be deleted on uninstallation.

If you're adding a node type, you're presuming adding additional tables to store the data for those nodes, so you'd be removing that anyway. There's not really any point in keeping around an unusable node record.
 
Back
Top Bottom