mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
Better fix for #106 using DataQuery queryParams. Thanks simon_w
This commit is contained in:
parent
586d88562c
commit
23e9cd40a0
@ -25,8 +25,9 @@ class SiteTreeSubsites extends DataExtension {
|
||||
/**
|
||||
* Update any requests to limit the results to the current site
|
||||
*/
|
||||
function augmentSQL(SQLQuery &$query) {
|
||||
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
|
||||
if(Subsite::$disable_subsite_filter) return;
|
||||
if($dataQuery->getQueryParam('Subsite.filter') === false) return;
|
||||
|
||||
// Don't run on delete queries, since they are always tied to
|
||||
// a specific ID.
|
||||
|
@ -646,12 +646,8 @@ JS;
|
||||
}
|
||||
|
||||
static function get_from_all_subsites($className, $filter = "", $sort = "", $join = "", $limit = "") {
|
||||
$oldState = self::$disable_subsite_filter;
|
||||
self::$disable_subsite_filter = true;
|
||||
$result = DataObject::get($className, $filter, $sort, $join, $limit);
|
||||
// conversion to ArrayList forces immediate evaluation, respecting subsite filter setting
|
||||
$result = ArrayList::create($result->toArray());
|
||||
self::$disable_subsite_filter = $oldState;
|
||||
$result = $result->setDataQueryParam('Subsite.filter', false);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user