Umbraco-CMS
Umbraco-CMS copied to clipboard
Fixes issue with the IVirtualPageController not setting PublishedRequest content via FindContent
Prerequisites
- [X] I have added steps to test this contribution in the description below
If there's an existing issue for this PR then this fixes https://github.com/umbraco/Umbraco-CMS/issues/12834
Description
This fixes an issue with the IUmbracoContextAccessor.PublishedRequest.PublishedContent not being set when a page is requested via an IVirtualPageController.
The issue (https://github.com/umbraco/Umbraco-CMS/issues/12834) has a comment from Kenn Jacobsen (https://github.com/umbraco/Umbraco-CMS/issues/12834#issuecomment-1350503166) which recreates the issue and you can see the PublishedContent via the UmbracoContext is null. With this fix the PublishedRequest is set from the content returned from IVirtualPageController FindContent method. Use Ken's code from the issue to test this.
I have also followed the tests outlined in https://github.com/umbraco/Umbraco-CMS/pull/13103 to ensure that existing functionality regarding virtual page controllers works as expected (as there are some comprehensive test scenarios in that PR).
All tests have been run and passed.
Hi there @justin-nevitech, thank you for this contribution! 👍
While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
- It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
- The automated tests all pass (see "Checks" tab on this PR)
- The level of security for this contribution is the same or improved
- The level of performance for this contribution is the same or improved
- Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
- If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
- [x] 💡 The contribution looks original and the contributor is presumably allowed to share it
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.
If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.
Thanks, from your friendly Umbraco GitHub bot 🤖 🙂
Just a note, the issue mentions this is a problem in v10, v11, and v12 so it will need backporting.
Hi @justin-nevitech,
Thanks for your PR to fix #12834, where the IVirtualPageController
is not setting the Umbraco context PublishedRequest
content via FindContent.
One of the Core Collaborators team will review this as soon as possible 👍
Best wishes
Emma
Any update on this pease as this is blocking us on the development of a new website?
Hi @bergmania - could you take a look and see if this can be checked and merged please?
This one is on me, not on Bjarke. Sorry for the delay! As initial feedback I would say that you can't update the constructur of a public method on a public class as that is a breaking change. Additionally, it is rare that we would want to make an internal method public.
So if a different approach can be taken with that feedback in mind we can have a look at it!
Note to @benbracedigital - apparently there's a workaround so it should remove your blocker: https://github.com/umbraco/Umbraco-CMS/issues/12834#issuecomment-1300563809
Hi @nul800sebastiaan - thanks for the feedback, I will try and take another look when I have some time.
Hey @nul800sebastiaan. I've re-worked my solution based on your feedback. Could you review please?