Merge pull request #5215 from tractorcow/pulls/3.2/fix-folder-relativepath

BUG Fix File::getRelativePath() failing if parent folder is renamed
This commit is contained in:
Daniel Hensby 2016-03-21 09:09:12 +00:00
commit d2fa01fb17

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");