silverstripe / silverstripe-cms

Silverstripe CMS - this is a module for Silverstripe Framework rather than a standalone app. Use https://github.com/silverstripe/silverstripe-installer/ to set this up.
http://silverstripe.org/
BSD 3-Clause "New" or "Revised" License
515 stars 333 forks source link

SiteTree link tracking can cause a fatal error when a page type is removed #2460

Open kinglozzer opened 5 years ago

kinglozzer commented 5 years ago

If a page type is removed, records left in the SiteTreeLink table may still point to it with ParentClass='App\Model\RemovedPageClass'. This can result in a InjectorNotFound exception in the CMS (from the dependent pages logic), caused by this line:

https://github.com/silverstripe/silverstripe-cms/blob/a083fc5d5b625890f91098719aadbdf025f5a7c7/code/Model/SiteTree.php#L1822

$parentClass doesn’t exist any more once the page type has been removed

robbieaverill commented 5 years ago

What do you think the expected behaviour should be instead?

kinglozzer commented 5 years ago

That’s a tough one, I was thinking if (!class_exists($parentClass)) continue; but that could mean that the user isn’t notified about a dependent page. Although that is better than seeing an internal server error... :P

mandrew commented 2 months ago

Still affects v5, is it possible to add the label affects/v5? Could there be a way to resolve these dependencies somehow, when removing page types?