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
v8: Unpublishing a variant does not trigger Unpublished event #5410
Comments
I agree with @natashadecanha that it is a bit confusing that the act of unpublishing a culture variant triggers the Published event. However, it would also be confusing (and possibly even worse) if an Unpublished event was triggered. The event is related to the IContent rather than the individual culture variants so the Unpublished event could be misleading. With "Allow varying by culture" the ContentService.Unpublished seems to be triggered when all culture variants are unpublished at the same time. I think this is correct since this means that the entire IContent is in fact Unpublished. However, this should also be the case when the last culture variant is unpublished. Currently, unpublishing the last variant triggers the Published event. Maybe there is a need for specific events such as PublishedCulture and UnpublishedCulture with dedicated EventArgs? |
@linuselander Makes a valid point about the whole Like @linuselander says, I think Umbraco should just expand the It should actually also be renamed to |
Hi Team, any updates on this issue? |
Also hit by this, how can one see if a variant is being unpublished to do some custom stuff? |
We've been hit by this issue too :( Would be lovely to get any update on IF/WHEN it can be looked at? Seems like working with varianted content and processing it outside of the "standard" way is impossible (at least without extreme hacking what is risky as usual..). |
"Unpublishing" a variant doesn't unpublish IContent, it just saves the IContent (which contains variants) to exclude that variant from having a published version. There's a lot of design things going on here.
(see #5409 (comment)) Unpublishing the entire IContent item is the only time Unpublishing triggers. Variants are not IContent, variants are just sub data items of IContent. We cannot 'just' have the Unpublishing event fire for changing a variants published version state, this will have huge repercussions and breaking changes. Though there's a lot of 'rules' around how an IContent gets unpubished that I can't recall off the top of my head but taking into account things like unpublishing mandatory cultures and default cultures, etc... What can you do now? Possibly look at Please reply here if that does/doesn't do what you require. If it doesn't, If you want to dig deeper into the code to see what can/can't/should be done. Most of this stuff happens in Is this confusing? Yes I agree that it is and there should be a nicer and documented way to know when and which cultures have been 'unpublished'. Is this design weird? Yes I agree but dealing with breaking changes and trying to minimize impacts of moving between major versions comes with it's own pitfalls and weird things need to be done without vastly overhauling the DB schema, services and events (which we'll need to do at some point). I'm sure in the meantime it's possible to make this easier, or at least just documented if what you need already exists as examples in those tests. |
Yup, some docs to make sure people don't end up spending time on debugging this would be ace! |
Just to add to this, by setting a Mandatory language - then unpublishing that, unpublishes everything, and the Unpublish event 'does fire'... Have added some docs on how you work with variants in events here - if that makes sense to people? |
The reason that occurs is because unpublishing a mandatory language effectively unpublishes the entire node because nothing can be published if a mandatory language is not published. Variants don't have the notion of published or unpublished, only the node does. Variants are either:
They cannot be un-created. |
Thanks for all the chat on this issue, peeps. I think there's a good case for a docs update here but the issue itself can be closed. Emma |
Bug summary
The published event triggered every time I unblished a page. So I took a look in the code and saw that in the UnpublishCulture the PublishedState is set to Publishing instead of Unpublishing. So likely this is the problem. I tested it and it works on my machine :)
So I propose the following pull request for change. But I cannot be sure if this is on purpose or an accidental oversight or wat the repercussions are.
PR here
Specifics
Steps to reproduce
public void Initialize()
{
ContentService.Published += ContentService_Published;
ContentService.Unpublished += ContentService_Unpublished;
}
Expected result
Unpublished event triggers
Actual result
Published event triggers
*Edit:
After some more testing, I noticed that it only fails if you have a multilingual doctype ("Allow varying by culture"). See added screenshots
Without "allow varying by culture"
You can see that when I unpublish a page, the unpublish event gets triggered, as expected.
With "allow varying by culture"
You can see that when I unpublish a page, the publish event gets triggered, as not expected.
The text was updated successfully, but these errors were encountered: