Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/161323
Change subject: Make ArchivedFile load title regardless of how constructed.
......................................................................
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
---
M includes/filerepo/file/ArchivedFile.php
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/23/161323/1
diff --git a/includes/filerepo/file/ArchivedFile.php
b/includes/filerepo/file/ArchivedFile.php
index 8bf9040..effa3ee 100644
--- a/includes/filerepo/file/ArchivedFile.php
+++ b/includes/filerepo/file/ArchivedFile.php
@@ -264,6 +264,9 @@
// 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 @@
* @return Title
*/
public function getTitle() {
+ if ( !$this->title ) {
+ $this->load();
+ }
return $this->title;
}
--
To view, visit https://gerrit.wikimedia.org/r/161323
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9d25d6b159aa45696c318d8c4a8ef0adffb3e47
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits