From 68826357cccc287c59682d18a39f4138eb2957c4 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 8 Nov 2012 21:28:05 +1300 Subject: [PATCH] BUG Fixing non-object on file upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upload::load() assumes that a parent Folder always exists for a file upload, but that's not always the case, and a non-object error is given if no parent folder. Check the folder exists first beforeĀ getting the ID. --- filesystem/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesystem/Upload.php b/filesystem/Upload.php index ca87a8627..e3c3fa8d4 100644 --- a/filesystem/Upload.php +++ b/filesystem/Upload.php @@ -159,7 +159,7 @@ class Upload extends Controller { } if(file_exists($tmpFile['tmp_name']) && copy($tmpFile['tmp_name'], "$base/$relativeFilePath")) { - $this->file->ParentID = $parentFolder->ID; + $this->file->ParentID = $parentFolder ? $parentFolder->ID : 0; // This is to prevent it from trying to rename the file $this->file->Name = basename($relativeFilePath); $this->file->write();