From cf6b50fa13ba3c2744593eda625f4492929b89d9 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Thu, 18 Sep 2014 16:11:42 -0300 Subject: [PATCH] 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 --- includes/filerepo/file/ArchivedFile.php | 6 ++++++ 1 file changed, 6 insertions(+) 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; } -- 2.20.1