From 5c095cbd787bf71e30658536aafdbf8ea837aa1f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Dec 2008 01:12:44 +0000 Subject: Add unit tests to test growing and contracting the left and right pointers Added a delete method to ORM_MPTT that contracts the tree when an item is deleted --- core/models/item.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index 0f6e16e8..fbaca0e7 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -42,10 +42,13 @@ class Item_Model extends ORM_MPTT { public function delete() { $path = $this->file_path(); parent::delete(); - if ($this->is_album()) { - dir::unlink($path); - } else { - unlink($path); + // If there is no name, the path is invalid so don't try to delete + if (!empty($this->name)) { + if ($this->is_album()) { + dir::unlink($path); + } else { + unlink($path); + } } } -- cgit v1.2.3