r70296 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70295‎ | r70296 | r70297 >
Date:22:07, 1 August 2010
Author:hartman
Status:reverted (Comments)
Tags:
Comment:
Repair getDescriptionUrl() and getDescriptionText() Follow up to r69907 and r69908

All this functionality is now moved to File.php. for getDescriptionUrl there was no
real need to subclass this method, for getDescriptionText() there was, but
duplicating the code or changing the inheritence model of LocalFile and ForeignDBFile
seems too much work if an isLocal in File.php suffices.
Modified paths:
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignDBFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -1121,28 +1121,9 @@
11221122 /** scaleHeight inherited */
11231123 /** getImageSize inherited */
11241124
1125 - /**
1126 - * Get the URL of the file description page.
1127 - */
1128 - function getDescriptionUrl() {
1129 - return $this->title->getLocalUrl();
1130 - }
 1125+ /** getDescriptionUrl inherited */
 1126+ /** getDescriptionText inherited */
11311127
1132 - /**
1133 - * Get the HTML text of the description page
1134 - * This is not used by ImagePage for local files, since (among other things)
1135 - * it skips the parser cache.
1136 - */
1137 - function getDescriptionText() {
1138 - global $wgParser;
1139 - $revision = Revision::newFromTitle( $this->title );
1140 - if ( !$revision ) return false;
1141 - $text = $revision->getText();
1142 - if ( !$text ) return false;
1143 - $pout = $wgParser->parse( $text, $this->title, new ParserOptions() );
1144 - return $pout->getText();
1145 - }
1146 -
11471128 function getDescription() {
11481129 $this->load();
11491130 return $this->description;
Index: trunk/phase3/includes/filerepo/ForeignDBFile.php
@@ -36,14 +36,4 @@
3737 function move( $target ) {
3838 $this->readOnlyError();
3939 }
40 -
41 - function getDescriptionUrl() {
42 - // Restore remote behaviour
43 - return parent::getDescriptionUrl();
44 - }
45 -
46 - function getDescriptionText() {
47 - // Restore remote behaviour
48 - return parent::getDescriptionText();
49 - }
5040 }
Index: trunk/phase3/includes/filerepo/File.php
@@ -1078,8 +1078,19 @@
10791079
10801080 /**
10811081 * Get the HTML text of the description page, if available
 1082+ * For local files ImagePage does not use it, because it skips the parser cache.
10821083 */
10831084 function getDescriptionText() {
 1085+ if( $this->isLocal() ) {
 1086+ global $wgParser;
 1087+ $revision = Revision::newFromTitle( $this->title );
 1088+ if ( !$revision ) return false;
 1089+ $text = $revision->getText();
 1090+ if ( !$text ) return false;
 1091+ $pout = $wgParser->parse( $text, $this->title, new ParserOptions() );
 1092+ return $pout->getText();
 1093+ }
 1094+
10841095 global $wgMemc, $wgLang;
10851096 if ( !$this->repo->fetchDescription ) {
10861097 return false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r83114Revert r69907, r69908, r70264, r70296: introduces bug 27477....btongminh21:06, 2 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69907Pass $this->getName() to getLocalUrlreedy20:55, 25 July 2010
r69908File:: to parent::reedy20:56, 25 July 2010

Comments

#Comment by Reedy (talk | contribs)   22:33, 1 August 2010
if ( !$revision) return false;
if ( !$text ) return false;

Should really have braces in them

#Comment by Bryan (talk | contribs)   21:51, 1 December 2010

Good fix.

Status & tagging log