umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.42k stars 2.67k forks source link

No OOD.flag is created when using SourceCodeManual and Development Runtime #14965

Closed splab closed 11 months ago

splab commented 11 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

11.4.2

Bug summary

When using SourceCodeManual and Umbraco:CMS:Runtime is set to Development, notificationhandlers for generating ood.flag is never registered, which means ModelsBuilder wont detect changes to content models or types.

Specifics

In src\Umbraco.Web.Common\ModelsBuilder\DependencyInjection\UmbracoBuilderDependencyInjectionExtensions.cs line 111 to 131 different notificationhandlers are registered. OutOfDateModelsStatus is only registered for BackofficeDevelopment, which means you can end up with a modelsbuilder (and developer) that think it's registered for SourceCodeManual and OutOfDate flagging, but no changes are ever reported.

Steps to reproduce

In appsettings, set:

"Umbraco":  {
    "CMS": {
     ...
    "Runtime": "Development",

    "ModelsBuilder": {

         "FlagOutOfDateModels": true,

         "ModelsMode": "SourceCodeManual"

     }
....

When changing documents or types, no OOD.flag file will be generated and models builder will look like this:

image

Expected result / actual result

When chaning content type or data types, we expect to see:

image

and a ood.flag file created in the published models folder.

Adding:

        builder.AddNotificationHandler<ContentTypeCacheRefresherNotification, OutOfDateModelsStatus>();
        builder.AddNotificationHandler<DataTypeCacheRefresherNotification, OutOfDateModelsStatus>();

to:

    if (builder.Config.GetRuntimeMode() != RuntimeMode.Production)
    {
        // Configure service to allow models generation
        builder.AddNotificationHandler<ServerVariablesParsingNotification, ModelsBuilderNotificationHandler>();
        builder.AddNotificationHandler<TemplateSavingNotification, ModelsBuilderNotificationHandler>();

        builder.AddNotificationHandler<UmbracoApplicationStartingNotification, AutoModelsNotificationHandler>();
        builder.AddNotificationHandler<UmbracoRequestEndNotification, AutoModelsNotificationHandler>();
        builder.AddNotificationHandler<ContentTypeCacheRefresherNotification, AutoModelsNotificationHandler>();
        builder.AddNotificationHandler<DataTypeCacheRefresherNotification, AutoModelsNotificationHandler>();
    }

Will fix this issue.

github-actions[bot] commented 11 months ago

Hi there @splab!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

jannikanker commented 11 months ago

Hm, looks weird. I'll gladly take a stab at it!

jannikanker commented 11 months ago

Draft PR ready, but I need to be sure that this is indeed a code bug and not a documentation error. It's pretty clear (to me, at least) that https://docs.umbraco.com/umbraco-cms/fundamentals/setup/server-setup/runtime-modes#development-mode says you should be able to do SourceCodeManual with flagging while in Development runtime mode... Anyone? :-D