mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX: Better handling of non-existent records in delete calls (if button is clicked twice) (by sminnee, merged from r100473)
This commit is contained in:
parent
1499a3c13a
commit
74f9649ac9
@ -617,6 +617,8 @@ JS;
|
||||
$id = $_REQUEST['ID'];
|
||||
Versioned::reading_stage('Live');
|
||||
$record = DataObject::get_by_id("SiteTree", $id);
|
||||
|
||||
if(!$record || !$record->ID) throw new HTTPResponse_Exception("Bad record ID #$id", 404);
|
||||
if($record && !($record->canDelete() && $record->canDeleteFromLive())) return Security::permissionFailure($this);
|
||||
|
||||
$descRemoved = '';
|
||||
@ -697,7 +699,10 @@ JS;
|
||||
"SiteTree",
|
||||
sprintf("\"SiteTree\".\"ID\" = %d", Convert::raw2sql($data['ID']))
|
||||
);
|
||||
if(!$record) return $this->httpError(400);
|
||||
|
||||
// Non-existent record
|
||||
if(!$record || !$record->ID) throw new HTTPResponse_Exception("Bad record ID #$id", 404);
|
||||
|
||||
if(!$record->canDelete()) return Security::permissionFailure();
|
||||
|
||||
// save ID and delete record
|
||||
|
@ -847,6 +847,9 @@ JS;
|
||||
* @return string
|
||||
*/
|
||||
public function deleteTreeNodeJS($page) {
|
||||
// Silently skip if $page isn't a record
|
||||
if (!$page || (!isset($page->ID) && !isset($page->OldID))) return false;
|
||||
|
||||
$id = $page->ID ? $page->ID : $page->OldID;
|
||||
$response = <<<JS
|
||||
var node = $('sitetree').getTreeNodeByIdx($id);
|
||||
|
Loading…
Reference in New Issue
Block a user