Merge pull request #727 from nathanbrauer/feature/update-for-versioned-1.12

Bugfix: Updating BlogPostFilter::augmentSQL to make use of modern Versioned methods.
This commit is contained in:
Sabina Talipova 2023-09-26 08:51:37 +13:00 committed by GitHub
commit 4ca99d07f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,13 +28,17 @@ class BlogPostFilter extends DataExtension
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{
$stage = Versioned::get_stage();
if (Controller::has_curr() && Controller::curr() instanceof LeftAndMain) {
return;
}
if ($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) {
if (Versioned::get_stage() === Versioned::LIVE ||
(
Versioned::get_draft_site_secured() &&
!Permission::check('VIEW_DRAFT_CONTENT')
)
) {
$query->addWhere(sprintf(
'"PublishDate" < \'%s\'',
Convert::raw2sql(DBDatetime::now())