mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUG Unused variable put to use. Doesn't show future posts on live stage
This commit is contained in:
parent
b0cbae816f
commit
81fdf81203
@ -15,15 +15,10 @@ class BlogPostFilter extends DataExtension {
|
|||||||
* Augment queries so that we don't fetch unpublished articles.
|
* Augment queries so that we don't fetch unpublished articles.
|
||||||
**/
|
**/
|
||||||
public function augmentSQL(SQLQuery &$query) {
|
public function augmentSQL(SQLQuery &$query) {
|
||||||
|
$stage = Versioned::current_stage();
|
||||||
if(!Permission::check("VIEW_DRAFT_CONTENT")) {
|
if($stage == 'Live' || !Permission::check("VIEW_DRAFT_CONTENT")) {
|
||||||
$stage = Versioned::current_stage();
|
|
||||||
if($stage == "Stage") $stage = "";
|
|
||||||
else $stage = "_" . Convert::raw2sql($stage);
|
|
||||||
|
|
||||||
$query->addWhere("PublishDate < '" . Convert::raw2sql(SS_Datetime::now()) . "'");
|
$query->addWhere("PublishDate < '" . Convert::raw2sql(SS_Datetime::now()) . "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,37 +58,37 @@ class BlogTest extends SapphireTest {
|
|||||||
$response = Director::test($archiveLink);
|
$response = Director::test($archiveLink);
|
||||||
$this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
$this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
||||||
|
|
||||||
// $archiveLink = Controller::join_links($blog->Link("archive"), 2013, 10);
|
$archiveLink = Controller::join_links($blog->Link("archive"), 2013, 10);
|
||||||
// $response = Director::test($archiveLink);
|
$response = Director::test($archiveLink);
|
||||||
// $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
$this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
||||||
|
|
||||||
// $archiveLink = Controller::join_links($blog->Link("archive"), 2013);
|
$archiveLink = Controller::join_links($blog->Link("archive"), 2013);
|
||||||
// $response = Director::test($archiveLink);
|
$response = Director::test($archiveLink);
|
||||||
// $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
$this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
||||||
|
|
||||||
// $archiveLink = Controller::join_links($blog->Link("archive"), 2011, 10, 01);
|
$archiveLink = Controller::join_links($blog->Link("archive"), 2011, 10, 01);
|
||||||
// $response = Director::test($archiveLink); // No posts on this date, but a valid entry.
|
$response = Director::test($archiveLink); // No posts on this date, but a valid entry.
|
||||||
// $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
$this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
|
||||||
|
|
||||||
|
|
||||||
// // Test invalid links & dates
|
// Test invalid links & dates
|
||||||
// $response = Director::test($blog->Link("archive")); // 404 when no date is set
|
$response = Director::test($blog->Link("archive")); // 404 when no date is set
|
||||||
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
$this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
||||||
|
|
||||||
// // Invalid year
|
// Invalid year
|
||||||
// $archiveLink = Controller::join_links($blog->Link("archive"), "invalid-year");
|
$archiveLink = Controller::join_links($blog->Link("archive"), "invalid-year");
|
||||||
// $response = Director::test($archiveLink); // 404 when an invalid yer is set
|
$response = Director::test($archiveLink); // 404 when an invalid yer is set
|
||||||
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
$this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
||||||
|
|
||||||
// // Invalid month
|
// Invalid month
|
||||||
// $archiveLink = Controller::join_links($blog->Link("archive"), "2013", "99");
|
$archiveLink = Controller::join_links($blog->Link("archive"), "2013", "99");
|
||||||
// $response = Director::test($archiveLink); // 404 when an invalid month is set
|
$response = Director::test($archiveLink); // 404 when an invalid month is set
|
||||||
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
$this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
||||||
|
|
||||||
// // Invalid day
|
// Invalid day
|
||||||
// $archiveLink = Controller::join_links($blog->Link("archive"), "2013", "10", "99");
|
$archiveLink = Controller::join_links($blog->Link("archive"), "2013", "10", "99");
|
||||||
// $response = Director::test($archiveLink); // 404 when an invalid day is set
|
$response = Director::test($archiveLink); // 404 when an invalid day is set
|
||||||
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
$this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user