From: Brian Wolff Date: Thu, 18 Sep 2014 19:11:42 +0000 (-0300) Subject: Make ArchivedFile load title regardless of how constructed. X-Git-Tag: 1.31.0-rc.0~13939^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=cf6b50fa13ba3c2744593eda625f4492929b89d9;p=lhc%2Fweb%2Fwiklou.git Make ArchivedFile load title regardless of how constructed. If someone did $f = new ArchivedFile( null, 10 ); (ie load an archived file based on id), $f->getTitle() would always return false. We should populate the title when loading properties from the db to prevent this. Having $f->getTitle() return false only sometimes is sketchy. Change-Id: Ia9d25d6b159aa45696c318d8c4a8ef0adffb3e47 --- diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index 8bf90402f1..effa3eeb70 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -264,6 +264,9 @@ class ArchivedFile { // old row, populate from key $this->sha1 = LocalRepo::getHashFromKey( $this->key ); } + if ( !$this->title ) { + $this->title = Title::makeTitleSafe( NS_FILE, $row->fa_name ); + } } /** @@ -272,6 +275,9 @@ class ArchivedFile { * @return Title */ public function getTitle() { + if ( !$this->title ) { + $this->load(); + } return $this->title; }