How do i know if a page is in trashcan?

I created this bug, because PageIndexDocumentBuilder is re adding pages in the trashcan to the index.

But can i solve this by myself? Is there any way of knowing if a page is in the trashcan?

Litium version: 8.2.1

Found it

page.Status == ContentStatus.InTrashCan 
2 Likes

There’s also an extension page.IsInTrashCan().

1 Like

Aha thanks, Litium.Application is not used in Litium.Accelerator.Elasticsearch so the intellisense did not pick it up.

I see that IsRoot() and InTrashCan() is in Litium.Application and IsActive() is in Litium.Abstractions?
And the only documentation is for IsActive. Should they be merged to the same project?

Yeah, IsActive will also check trashcan status, so would be the better option so you don’t need to include the Litium.Application package. Or just run with your original solution :slight_smile:

1 Like

The IsActive is also checking if the page currently is active for the channel and for indexing you want to index pages that have the start/end date for activation on the channel outside the current time.

page.Status == ContentStatus.InTrashCan is the check you should have in the code to skip indexing of the pages that are in trashcan.

Backward compatibility is only maintained for *.Abstractions assemblies with notification of breaking changes in release notes. Using classes or methods from the application assemblies can introduce that the code is not working after upgrade and manually extra work need to be added to get the solution to work as expected again.

1 Like

Just by looking at the code in PageIndexDocumentBuilder.cs it looks like a page, in the channel but with expired end date should end up in the index. But it does not? There is nothing checking end date from what I can see.

It feels like IsActive is a must in PageIndexDocumentBuilder but in reality page.Status == ContentStatus.InTrashCan seems to enough.

Thanks for the explanation about *.Abstractions.

Edit:
Oh i see now, the page ends up in the index if the end date is set, but Litium.Search.SearchExtensions.PublishedOnChannel is excluding it from the search.

So IsActive is a matter of situation, depending on how you want to use the page index, but page.Status == ContentStatus.InTrashCan should be in PageIndexDocumentBuilder.cs from the start because there are events that remove the page from the index when you add it to the trash can, so they should not be added back on a re index

Yes, that is correct.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.