From 792c9058fa210ba0fd8e3fec4b812fffe988bd9c Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 15 Jun 2012 15:30:08 +1200 Subject: [PATCH] BUGFIX: Fixed DataList operations to respect the fact that they're idempotent. --- code/controllers/AssetAdmin.php | 8 ++++---- code/controllers/CMSMain.php | 6 +++--- code/reports/BrokenLinksReport.php | 2 +- code/reports/Report.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index de15dfc0..57807b21 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -102,7 +102,7 @@ JS // Re-add previously removed "Name" filter as combined filter // TODO Replace with composite SearchFilter once that API exists if(isset($params['Name'])) { - $list->where(sprintf( + $list = $list->where(sprintf( '"Name" LIKE \'%%%s%%\' OR "Title" LIKE \'%%%s%%\'', Convert::raw2sql($params['Name']), Convert::raw2sql($params['Name']) @@ -110,12 +110,12 @@ JS } // Always show folders at the top - $list->sort('(CASE WHEN "File"."ClassName" = \'Folder\' THEN 0 ELSE 1 END), "Name"'); + $list = $list->sort('(CASE WHEN "File"."ClassName" = \'Folder\' THEN 0 ELSE 1 END), "Name"'); // If a search is conducted, check for the "current folder" limitation. // Otherwise limit by the current folder as denoted by the URL. if(!$params || @$params['CurrentFolderOnly']) { - $list->filter('ParentID', $folder->ID); + $list = $list->filter('ParentID', $folder->ID); } // Category filter @@ -124,7 +124,7 @@ JS $categorySQLs = array(); foreach($exts as $ext) $categorySQLs[] = '"File"."Name" LIKE \'%.' . $ext . '\''; // TODO Use DataList->filterAny() once OR connectives are implemented properly - $list->where('(' . implode(' OR ', $categorySQLs) . ')'); + $list = $list->where('(' . implode(' OR ', $categorySQLs) . ')'); } return $list; diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 9ca97dd5..bde6b32f 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -477,7 +477,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ))); } - $result->sort('AddAction'); + $result = $result->sort('AddAction'); return $result; } @@ -658,9 +658,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr foreach($pages=$filter->pagesIncluded() as $pageMap){ $ids[] = $pageMap['ID']; } - if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')'); + if(count($ids)) $list = $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')'); } else { - $list->filter("ParentID", is_numeric($parentID) ? $parentID : 0); + $list = $list->filter("ParentID", is_numeric($parentID) ? $parentID : 0); } return $list; diff --git a/code/reports/BrokenLinksReport.php b/code/reports/BrokenLinksReport.php index 76603ab7..57051859 100644 --- a/code/reports/BrokenLinksReport.php +++ b/code/reports/BrokenLinksReport.php @@ -69,7 +69,7 @@ class BrokenLinksReport extends SS_Report { } } - if($sortBrokenReason) $returnSet->sort('BrokenReason', $direction); + if($sortBrokenReason) $returnSet = $returnSet->sort('BrokenReason', $direction); return $returnSet; } diff --git a/code/reports/Report.php b/code/reports/Report.php index fb0ad216..1a1bd5ea 100644 --- a/code/reports/Report.php +++ b/code/reports/Report.php @@ -206,7 +206,7 @@ class SS_Report extends ViewableData { $list = ArrayList::create($reportsArray); //sort - $list->sort('sort'); + $list = $list->sort('sort'); return $list; }