Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with the IVirtualPageController not setting PublishedRequest content via FindContent #15121

Merged
merged 7 commits into from
Jan 14, 2025

Conversation

justin-nevitech
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes #12834

Description

This fixes an issue with the IUmbracoContextAccessor.PublishedRequest.PublishedContent not being set when a page is requested via an IVirtualPageController.

The issue (#12834) has a comment from Kenn Jacobsen (#12834 (comment)) 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 #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.

Copy link

github-actions bot commented Nov 2, 2023

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
  • 💡 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 🤖 🙂

@justin-nevitech
Copy link
Contributor Author

Just a note, the issue mentions this is a problem in v10, v11, and v12 so it will need backporting.

@emmagarland emmagarland changed the title Fixes issue https://github.com/umbraco/Umbraco-CMS/issues/12834 Fixes issue with the IVirtualPageController not setting PublishedRequest content via FindContent Nov 3, 2023
@emmagarland
Copy link
Contributor

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

@benbracedigital
Copy link

Any update on this pease as this is blocking us on the development of a new website?

@justin-nevitech
Copy link
Contributor Author

Hi @bergmania - could you take a look and see if this can be checked and merged please?

@nul800sebastiaan
Copy link
Member

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!

@nul800sebastiaan
Copy link
Member

Note to @benbracedigital - apparently there's a workaround so it should remove your blocker: #12834 (comment)

@justin-nevitech
Copy link
Contributor Author

Hi @nul800sebastiaan - thanks for the feedback, I will try and take another look when I have some time.

@justin-nevitech
Copy link
Contributor Author

Hey @nul800sebastiaan. I've re-worked my solution based on your feedback. Could you review please?

@Zeegaan
Copy link
Member

Zeegaan commented Jan 14, 2025

Sorry for the slow reply here, I like the solution, and it works like a charm 🚀
I took the liberty of obsoleting the old ctor and creating a new, so we can use proper DI 😁
Will merge when the tests are happy, and thanks again for the fix 🙌

@Zeegaan Zeegaan merged commit fd9c1a0 into umbraco:contrib Jan 14, 2025
27 checks passed
Zeegaan pushed a commit that referenced this pull request Jan 14, 2025
…est content via FindContent (#15121)

* Fixes issue #12834

* Re-worked based on feedback

* Use dependency injection

* Only call new constructor

---------

Co-authored-by: Nikolaj Geisle <[email protected]>
(cherry picked from commit fd9c1a0)
@Zeegaan
Copy link
Member

Zeegaan commented Jan 14, 2025

Cherry picked for 13.6 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IVirtualPageController is not setting the Umbraco context PublishedRequest content via FindContent
6 participants