BUG Fix File::getRelativePath() failing if parent folder is renamed

Fixes #4993
This commit is contained in:
Damian Mooyman 2016-03-21 17:22:38 +13:00
parent cbdaf890dd
commit 5f8356d686

View File

@ -743,7 +743,9 @@ class File extends DataObject {
if($this->ParentID) {
// Don't use the cache, the parent has just been changed
$p = DataObject::get_by_id('Folder', $this->ParentID, false);
if($p && $p->exists()) return $p->getRelativePath() . $this->getField("Name");
if($p && $p->isInDB()) {
return $p->getRelativePath() . $this->getField("Name");
}
else return ASSETS_DIR . "/" . $this->getField("Name");
} else if($this->getField("Name")) {
return ASSETS_DIR . "/" . $this->getField("Name");