umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
Other
4.49k stars 2.69k forks source link

Media types - Generated model is missing property until second save. #8276

Closed rndfm closed 2 years ago

rndfm commented 4 years ago

When I'm updating a mediatype with a new property it's not available on the generated published model. If i save once again it becomes available.

The same but opposite happens when a property is deleted. On first save its still available on the generated model. Save twice and the property is gone.

Only tried with properties on Media types.

I am seeing this issue on Umbraco version: 8.6.2

Reproduction

Create a custom media type. Save it. Create a view that looks up a some media of that type. Add an extra property to the media type. Press save. ( In my example i added a property with a Label(String) editor) Try to use that property in the view. Expect to see a "'Umbraco.Web.PublishedModels.X' does not contain a definition for 'X'" Press save once more. Reload the page and suddenly the property works as expected.

Expected result Property should be available on the generated model on first save.

Actual result Property not available on the generated model in first save. Save twice and the property is available.

image

nul800sebastiaan commented 4 years ago

Hi @rndfm - Apologies for the late reply! Could you clarify what Modelsbuilder mode you're using please? And I assume you're using the built-in Modelsbuilder and haven't installed the community Modelsbuilder package?

nul800sebastiaan commented 4 years ago

Got it, I can reproduce this in PureLive mode as well, the same problem for document types (and I presume member types).

To access the item in the template I used var mediaItem = Umbraco.Media(1151) as ContentModels.TestType; and then accessing mediaItem.TestProperty doesn't work if the property was just added new.

If I look at all.generated.cs between saving the doctype/mediatype the first and the second time nothing changes except for the version number at the top. It looks like some cache doesn't get cleared on time. I can also see that the all.generated.cs doesn't get updated at all until I reload the page on the frontend, not sure how that was supposed to work.

Finally: if you save it once and then recycle the app pool, the new property will be available as well, so it's definitely some kind of cache thing not being invalidated correctly.

nul800sebastiaan commented 4 years ago

Just tried this out in Umbraco 8.4 as well and it was a problem there as well so this bug has existed for a while.

We'd love some help on getting this fixed! 👍

umbrabot commented 4 years ago

Hi @rndfm,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post

Thanks muchly, from your friendly Umbraco GitHub bot :-)

rndfm commented 4 years ago

Hi @rndfm - Apologies for the late reply! Could you clarify what Modelsbuilder mode you're using please? And I assume you're using the built-in Modelsbuilder and haven't installed the community Modelsbuilder package?

Hi @nul800sebastiaan Yes this is a "stock" umbraco installation. No changes to the modelsbuilder

FransdeJong commented 3 years ago

Nevermind. This is a separate issue. I'll create a new issue

umbrabot commented 2 years ago

Hiya @rndfm,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

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

rndfm commented 2 years ago

@nul800sebastiaan Did this ever get fixed?

nul800sebastiaan commented 2 years ago

Doesn't look like it, feel free to shoot us a pull request!