BUGFIX #4486 Make use of DataObject::get_by_id() in File::getRelativePath() instead of building ID query manually in a get_one()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84843 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-08-19 23:39:39 +00:00
parent c9af2765b2
commit f7dc370b16

View File

@ -434,16 +434,12 @@ class File extends DataObject {
}
function getRelativePath() {
if($this->ParentID) {
$p = DataObject::get_one('Folder', "\"ID\"={$this->ParentID}");
if($p && $p->ID) return $p->getRelativePath() . $this->getField("Name");
$p = DataObject::get_by_id('Folder', $this->ParentID);
if($p && $p->exists()) return $p->getRelativePath() . $this->getField("Name");
else return ASSETS_DIR . "/" . $this->getField("Name");
} else if($this->getField("Name")) {
return ASSETS_DIR . "/" . $this->getField("Name");
} else {
return ASSETS_DIR;
}