I have News as Pages with collectionDatePublic (core attr) that can be set to the future to schedule news publishing.
However, if the url is guessed the page is reachable even before the public date and even worse, the page shows up in the search long before it reaches its public date.
How can i fix this? Is this intended behaviour?
I tried to hack concrete/src/Page/Controller/PageController::getSearchableCotnent() to return an empty string but that changed nothing. (the text that gets found by the search is in the page description or the page title, i can exclude blocks from the search index)
I tried to create NewsPages with publish date in the future as draft. They then do not get indexed and do not show up in the search BUT they won’t get out of the draft state when the publish date is reached and stay inaccessible to the Visitors. So that is of no use.
I now checked after creating the Page with publish date in the future:
I could find a fix for my Problem. I can change the two functions “pagesToQueue()” in jobs/index_search.php and jobs/indes_search_all.php to only include approved and public Pages:
// Find all pages that need indexing
$query = $qb
->select('p.cID')
->from('Pages', 'p')
->leftJoin('p', 'CollectionSearchIndexAttributes', 'a', 'p.cID = a.cID')
->leftJoin('p', 'Collections', 'c', 'p.cID = c.cID')
->leftJoin('p', 'PageSearchIndex', 's', 'p.cID = s.cID')
->leftJoin('p', 'CollectionVersions', 'cv', 'p.cID = cv.cID') //we need this to add the where down below
->where('cIsActive = 1')
->andWhere('cv.cvIsApproved = 1') // this is new
->andWhere('cv.cvDatePublic < NOW()') //this is new
->andWhere($qb->expr()->orX(
'a.ak_exclude_search_index is null',
'a.ak_exclude_search_index = 0'
))
->andWhere($qb->expr()->orX(
'cDateModified > s.cDateLastIndexed',
"(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(s.cDateLastIndexed) > {$timeout})",
's.cID is null',
's.cDateLastIndexed is null'
))->execute();
Soo that leaves me frustrated and with an open question: Is it the intended way to index unpublished sites for search?
@donat I don’t imagine that’s the intended behavior - probably worth opening an issue in the core project to get some attention / discussion on that because I agree that doesn’t seem desirable.