Skip to content

Commit

Permalink
Bugfix: Updating BlogPostFilter::augmentSQL to make use of modern Ver…
Browse files Browse the repository at this point in the history
…sioned methods.

This resolves an issue with some modules that rely upon get_draft_site_secured, like Elemental and sharedraftcontent
  • Loading branch information
nathanbrauer committed Sep 20, 2023
1 parent 9d3a398 commit 7128123
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Model/BlogPostFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 7128123

Please sign in to comment.