jenkins-bot has submitted this change and it was merged.
Change subject: Add option to chose what language to fetch file description in.
......................................................................
Add option to chose what language to fetch file description in.
I want to get the file description in a language other then
the user language in an extension (I5e6bc45f9751).
Change-Id: Ifcae821a51f4207e7816e710d3b3857c7ed438b6
---
M includes/filerepo/file/File.php
M includes/filerepo/file/ForeignDBFile.php
M includes/filerepo/file/LocalFile.php
3 files changed, 14 insertions(+), 7 deletions(-)
Approvals:
Anomie: Looks good to me, but someone else must approve
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index 9060731..79fad2e 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -1656,18 +1656,22 @@
/**
* Get the HTML text of the description page, if available
*
+ * @param $lang Language Optional language to fetch description in
* @return string
*/
- function getDescriptionText() {
+ function getDescriptionText( $lang = false ) {
global $wgMemc, $wgLang;
if ( !$this->repo || !$this->repo->fetchDescription ) {
return false;
}
- $renderUrl = $this->repo->getDescriptionRenderUrl(
$this->getName(), $wgLang->getCode() );
+ if ( !$lang ) {
+ $lang = $wgLang;
+ }
+ $renderUrl = $this->repo->getDescriptionRenderUrl(
$this->getName(), $lang->getCode() );
if ( $renderUrl ) {
if ( $this->repo->descriptionCacheExpiry > 0 ) {
wfDebug( "Attempting to get the description
from cache..." );
- $key = $this->repo->getLocalCacheKey(
'RemoteFileDescription', 'url', $wgLang->getCode(),
+ $key = $this->repo->getLocalCacheKey(
'RemoteFileDescription', 'url', $lang->getCode(),
$this->getName() );
$obj = $wgMemc->get( $key );
if ( $obj ) {
diff --git a/includes/filerepo/file/ForeignDBFile.php
b/includes/filerepo/file/ForeignDBFile.php
index ee5883c..01d6b0f 100644
--- a/includes/filerepo/file/ForeignDBFile.php
+++ b/includes/filerepo/file/ForeignDBFile.php
@@ -120,10 +120,11 @@
}
/**
+ * @param $lang Language Optional language to fetch description in.
* @return string
*/
- function getDescriptionText() {
+ function getDescriptionText( $lang = false ) {
// Restore remote behavior
- return File::getDescriptionText();
+ return File::getDescriptionText( $lang );
}
}
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index 39ef62c..d99ed6e 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1664,9 +1664,11 @@
* Get the HTML text of the description page
* This is not used by ImagePage for local files, since (among other
things)
* it skips the parser cache.
+ *
+ * @param $lang Language What language to get description in (Optional)
* @return bool|mixed
*/
- function getDescriptionText() {
+ function getDescriptionText( $lang = null ) {
$revision = Revision::newFromTitle( $this->title, false,
Revision::READ_NORMAL );
if ( !$revision ) {
return false;
@@ -1675,7 +1677,7 @@
if ( !$content ) {
return false;
}
- $pout = $content->getParserOutput( $this->title, null, new
ParserOptions() );
+ $pout = $content->getParserOutput( $this->title, null, new
ParserOptions( null, $lang ) );
return $pout->getText();
}
--
To view, visit https://gerrit.wikimedia.org/r/82085
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifcae821a51f4207e7816e710d3b3857c7ed438b6
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits