mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
c9af2765b2
commit
f7dc370b16
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user