Migration from SS3 to SS4.5 Page.php Problem with has_many relation

Silverstripe Version:4.5.2

I added a $has_many relationship to Page.php, which worked fine in SS3.6, but now I get an error when I dev/build it breaks at the ErrorPage: [Emergency] Uncaught InvalidArgumentException: has_many relation SilverStripe\ErrorPage\ErrorPage.HeaderImages references class HeaderImage which doesn’t exist

and when I try to open the page in the browser it’s: [Emergency] Uncaught InvalidArgumentException: has_many relation MyNamespace\HomePage.HeaderImages references class HeaderImage which doesn’t exist

I have on the HeaderImage private static $has_one = [‘Page’ => Page::class] and on
Page.php private static $has_many = [ ‘HeaderImages’ => HeaderImage::class] so nothing really changed between SS3.6 and SS4.5

Why doesn’t it work anymore?
Has anybody any idea?


It’s obviously a little hard to be too specific without seeing any code, but I’d say the first thing to check is your namespaces and use statements. If there’s a missing use in one of the class files, then PHP won’t be able to resolve the classnames properly.

Hi DorsetDigital,

Perfect! Thank you very much, that was exactly it.

Have a good day :grinning: