mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUG: AuthorID is still referenced and some of the SQL filters have the incorrect syntax
This commit is contained in:
parent
9a56f5aabf
commit
0a37428f5e
@ -270,19 +270,29 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
} else {
|
} else {
|
||||||
$filter = '';
|
$filter = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AuthorID has been removed from BlogEntry check for it incase it is an upgrade
|
||||||
|
$hasAuthorID = BlogEntry::get()->first()->hasDatabaseField('AuthorID');
|
||||||
|
|
||||||
// allow filtering by author field and some blogs have an authorID field which
|
// allow filtering by author field and some blogs have an authorID field which
|
||||||
// may allow filtering by id
|
// may allow filtering by id
|
||||||
if(isset($_GET['author']) && isset($_GET['authorID'])) {
|
if($hasAuthorID == true && isset($_GET['author']) && isset($_GET['authorID'])) {
|
||||||
$author = Convert::raw2sql($_GET['author']);
|
$author = Convert::raw2sql($_GET['author']);
|
||||||
$id = Convert::raw2sql($_GET['authorID']);
|
$id = Convert::raw2sql($_GET['authorID']);
|
||||||
|
|
||||||
$filter .= " \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'";
|
$filter .= (empty($filter)) ?
|
||||||
|
" \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'"
|
||||||
|
: " AND \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'";
|
||||||
}
|
}
|
||||||
else if(isset($_GET['author'])) {
|
else if(isset($_GET['author'])) {
|
||||||
$filter .= " \"BlogEntry\".\"Author\" LIKE '". Convert::raw2sql($_GET['author']) . "'";
|
$filter .= (empty($filter)) ?
|
||||||
|
" \"BlogEntry\".\"Author\" LIKE '". Convert::raw2sql($_GET['author']) . "'"
|
||||||
|
: " AND \"BlogEntry\".\"Author\" LIKE '". Convert::raw2sql($_GET['author']) . "'";
|
||||||
}
|
}
|
||||||
else if(isset($_GET['authorID'])) {
|
else if($hasAuthorID == true && isset($_GET['authorID'])) {
|
||||||
$filter .= " \"BlogEntry\".\"AuthorID\" = '". Convert::raw2sql($_GET['authorID']). "'";
|
$filter .= (empty($filter)) ?
|
||||||
|
" \"BlogEntry\".\"AuthorID\" = '%". Convert::raw2sql($_GET['authorID']). "%'"
|
||||||
|
: " AND \"BlogEntry\".\"AuthorID\" = '". Convert::raw2sql($_GET['authorID']). "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = $this->SelectedDate();
|
$date = $this->SelectedDate();
|
||||||
@ -369,7 +379,7 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
return $hasAuthor
|
return $hasAuthor
|
||||||
? $this->request->getVar('author')
|
? $this->request->getVar('author')
|
||||||
: null;
|
: null;
|
||||||
} elseif($this->request->getVar('authorID')) {
|
} elseif($this->request->getVar('authorID') && BlogEntry::get()->first()->hasDatabaseField('AuthorID')) {
|
||||||
$hasAuthor = BlogEntry::get()->filter('AuthorID', $this->request->getVar('authorID'))->Count();
|
$hasAuthor = BlogEntry::get()->filter('AuthorID', $this->request->getVar('authorID'))->Count();
|
||||||
if($hasAuthor) {
|
if($hasAuthor) {
|
||||||
$member = Member::get()->byId($this->request->getVar('authorID'));
|
$member = Member::get()->byId($this->request->getVar('authorID'));
|
||||||
|
Loading…
Reference in New Issue
Block a user