mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FIX Don't hardcode table name (#629)
BlogFilter had some hardcoded references to BlogPost table; when you rename this table, e.g. to "News", some joins broke.
This commit is contained in:
parent
799cc44b46
commit
bad865dc65
@ -35,10 +35,11 @@ class BlogFilter extends Lumberjack
|
||||
$stage = '_' . $stage;
|
||||
}
|
||||
|
||||
$blogPostTable = DataObject::getSchema()->tableName(BlogPost::class);
|
||||
$dataQuery = $staged->dataQuery()
|
||||
->innerJoin(
|
||||
DataObject::getSchema()->tableName(BlogPost::class),
|
||||
sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage)
|
||||
$blogPostTable,
|
||||
sprintf('"' . $blogPostTable . '%s"."ID" = "SiteTree%s"."ID"', $stage, $stage)
|
||||
)
|
||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||
|
||||
@ -64,10 +65,11 @@ class BlogFilter extends Lumberjack
|
||||
$staged = parent::liveChildren($showAll, $onlyDeletedFromStage);
|
||||
|
||||
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
$blogPostTable = DataObject::getSchema()->tableName(BlogPost::class);
|
||||
$dataQuery = $staged->dataQuery()
|
||||
->innerJoin(
|
||||
DataObject::getSchema()->tableName(BlogPost::class),
|
||||
'"BlogPost_Live"."ID" = "SiteTree_Live"."ID"'
|
||||
$blogPostTable,
|
||||
'"' . $blogPostTable . '_Live"."ID" = "SiteTree_Live"."ID"'
|
||||
)
|
||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user