Skip to content

Commit

Permalink
Merge pull request #727 from nathanbrauer/feature/update-for-versione…
Browse files Browse the repository at this point in the history
…d-1.12

Bugfix: Updating BlogPostFilter::augmentSQL to make use of modern Versioned methods.
  • Loading branch information
sabina-talipova authored Sep 25, 2023
2 parents 9d3a398 + 7128123 commit 4ca99d0
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 4ca99d0

Please sign in to comment.