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;
|
$stage = '_' . $stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$blogPostTable = DataObject::getSchema()->tableName(BlogPost::class);
|
||||||
$dataQuery = $staged->dataQuery()
|
$dataQuery = $staged->dataQuery()
|
||||||
->innerJoin(
|
->innerJoin(
|
||||||
DataObject::getSchema()->tableName(BlogPost::class),
|
$blogPostTable,
|
||||||
sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage)
|
sprintf('"' . $blogPostTable . '%s"."ID" = "SiteTree%s"."ID"', $stage, $stage)
|
||||||
)
|
)
|
||||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||||
|
|
||||||
@ -64,10 +65,11 @@ class BlogFilter extends Lumberjack
|
|||||||
$staged = parent::liveChildren($showAll, $onlyDeletedFromStage);
|
$staged = parent::liveChildren($showAll, $onlyDeletedFromStage);
|
||||||
|
|
||||||
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||||
|
$blogPostTable = DataObject::getSchema()->tableName(BlogPost::class);
|
||||||
$dataQuery = $staged->dataQuery()
|
$dataQuery = $staged->dataQuery()
|
||||||
->innerJoin(
|
->innerJoin(
|
||||||
DataObject::getSchema()->tableName(BlogPost::class),
|
$blogPostTable,
|
||||||
'"BlogPost_Live"."ID" = "SiteTree_Live"."ID"'
|
'"' . $blogPostTable . '_Live"."ID" = "SiteTree_Live"."ID"'
|
||||||
)
|
)
|
||||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user