From a3e55785aceb4c6ba8de8c45115d98bee6c8548f Mon Sep 17 00:00:00 2001 From: Mellisa Hankins Date: Thu, 11 Jul 2013 17:31:16 +1000 Subject: [PATCH] FIX: Missing returns, and checks if records were passed --- .../VersionedGridFieldBulkManager_Request.php | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/code/VersionedGridFieldBulkManager_Request.php b/code/VersionedGridFieldBulkManager_Request.php index add472e..ff0c3dc 100644 --- a/code/VersionedGridFieldBulkManager_Request.php +++ b/code/VersionedGridFieldBulkManager_Request.php @@ -25,26 +25,32 @@ class VersionedGridFieldBulkManager_Request extends GridFieldBulkManager_Request public function publish(SS_HTTPRequest $request) { $recordList = $this->getPOSTRecordList($request); - $records = $this->gridField->List->byIDs($recordList); - foreach($records as $record) { - if(!$this->doPublish($record)) - unset($recordList[$record->ID]); + if($recordList && count($recordList)) { + $records = $this->gridField->List->byIDs($recordList); + + foreach($records as $record) { + if(!$this->doPublish($record)) + unset($recordList[$record->ID]); + } } - $this->completeAction($recordList); + return $this->completeAction($recordList); } public function unpublish(SS_HTTPRequest $request) { $recordList = $this->getPOSTRecordList($request); - $records = $this->gridField->List->byIDs($recordList); - foreach($records as $record) { - if(!$this->doUnpublish($record)) - unset($recordList[$record->ID]); + if($recordList && count($recordList)) { + $records = $this->gridField->List->byIDs($recordList); + + foreach($records as $record) { + if(!$this->doUnpublish($record)) + unset($recordList[$record->ID]); + } } - $this->completeAction($recordList); + return $this->completeAction($recordList); } protected function doPublish($record) {