Silverstripe-framework 4 (4.5.3) is not properly decoupled from CMS

I am upgrading a web application from silverstripe-3 to silverstripe-4. This application was framework only, no CMS is needed.

In the new application when I log in I get this error:

# [Emergency] Uncaught InvalidArgumentException: Page is not a subclass of DataObject

After adding a dummy Page object, just to make it happy, I get another error:

# [Emergency] Uncaught Error: Class 'SilverStripe\CMS\Controllers\ModelAsController' not found

A quick look to the Security class shows some nasty dependency between framework and cms. I remember in the past a lot of effort had been put to decouple them… it seems odd this is gone, dead and buried.

Any solution that does not involve importing silverstripe-cms? Is this issue confined to the Security class?

Humm … I managed to get a admin-only site running (framework+admin without cms).

It’s certainly our intention that you should be able run Framework without CMS.

If the only problem is with the login page, you could try adding the silverstripe/login-forms module.

It’s probably worth raising a bug on this.

Yes, I iust found it still works fine. I thought the use clause automatically adds a dependency but it seems this is not the case.

The real issue was my fault: I was rendering the wrong template (the one from a custom theme instead of the one from my application). In SilverStripe 3 the template priority was implicit (and AFAIR it was relying on alphabetic order) so the app directory automatically took precedence over the theme but now I should set it explicitely with something like:

    - '$public'
    - '/app'
    - 'customtheme'
    - '$default'

I think the new approach is definitely better in every way: sorry for the noise.

1 Like