r22774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22773‎ | r22774 | r22775 >
Date:18:44, 5 June 2007
Author:brion
Status:old
Tags:
Comment:
* Add an Image::newFromName for additional compat
* Add 'static' markers on the static factory methods
Modified paths:
  • /trunk/phase3/includes/filerepo/ForeignDBFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/OldLocalFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/UnregisteredLocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/OldLocalFile.php
@@ -11,15 +11,15 @@
1212 const CACHE_VERSION = 1;
1313 const MAX_CACHE_ROWS = 20;
1414
15 - function newFromTitle( $title, $repo, $time ) {
 15+ static function newFromTitle( $title, $repo, $time ) {
1616 return new self( $title, $repo, $time, null );
1717 }
1818
19 - function newFromArchiveName( $title, $repo, $archiveName ) {
 19+ static function newFromArchiveName( $title, $repo, $archiveName ) {
2020 return new self( $title, $repo, null, $archiveName );
2121 }
2222
23 - function newFromRow( $row, $repo ) {
 23+ static function newFromRow( $row, $repo ) {
2424 $title = Title::makeTitle( NS_IMAGE, $row->oi_name );
2525 $file = new self( $title, $repo, null, $row->oi_archive_name );
2626 $file->loadFromRow( $row, 'oi_' );
Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -52,7 +52,7 @@
5353 * Create a LocalFile from a title
5454 * Do not call this except from inside a repo class.
5555 */
56 - function newFromTitle( $title, $repo ) {
 56+ static function newFromTitle( $title, $repo ) {
5757 return new self( $title, $repo );
5858 }
5959
@@ -60,7 +60,7 @@
6161 * Create a LocalFile from a title
6262 * Do not call this except from inside a repo class.
6363 */
64 - function newFromRow( $row, $repo ) {
 64+ static function newFromRow( $row, $repo ) {
6565 $title = Title::makeTitle( NS_IMAGE, $row->img_name );
6666 $file = new self( $title, $repo );
6767 $file->loadFromRow( $row );
@@ -1333,7 +1333,7 @@
13341334 * Do not use in core code.
13351335 * @deprecated
13361336 */
1337 - function newFromTitle( $title, $time = false ) {
 1337+ static function newFromTitle( $title, $time = false ) {
13381338 $img = wfFindFile( $title, $time );
13391339 if ( !$img ) {
13401340 $img = wfLocalFile( $title );
@@ -1342,6 +1342,27 @@
13431343 }
13441344
13451345 /**
 1346+ * Wrapper for wfFindFile(), for backwards-compatibility only.
 1347+ * Do not use in core code.
 1348+ *
 1349+ * @param string $name name of the image, used to create a title object using Title::makeTitleSafe
 1350+ * @return image object or null if invalid title
 1351+ * @deprecated
 1352+ */
 1353+ static function newFromName( $name ) {
 1354+ $title = Title::makeTitleSafe( NS_IMAGE, $name );
 1355+ if ( is_object( $title ) ) {
 1356+ $img = wfFindFile( $title );
 1357+ if ( !$img ) {
 1358+ $img = wfLocalFile( $title );
 1359+ }
 1360+ return $img;
 1361+ } else {
 1362+ return NULL;
 1363+ }
 1364+ }
 1365+
 1366+ /**
13461367 * Return the URL of an image, provided its name.
13471368 *
13481369 * Backwards-compatibility for extensions.
Index: trunk/phase3/includes/filerepo/UnregisteredLocalFile.php
@@ -13,11 +13,11 @@
1414 class UnregisteredLocalFile extends File {
1515 var $title, $path, $mime, $handler, $dims;
1616
17 - function newFromPath( $path, $mime ) {
 17+ static function newFromPath( $path, $mime ) {
1818 return new UnregisteredLocalFile( false, false, $path, $mime );
1919 }
2020
21 - function newFromTitle( $title, $repo ) {
 21+ static function newFromTitle( $title, $repo ) {
2222 return new UnregisteredLocalFile( $title, $repo, false, false );
2323 }
2424
Index: trunk/phase3/includes/filerepo/ForeignDBFile.php
@@ -1,7 +1,7 @@
22 <?php
33
44 class ForeignDBFile extends LocalFile {
5 - function newFromTitle( $title, $repo ) {
 5+ static function newFromTitle( $title, $repo ) {
66 return new self( $title, $repo );
77 }
88

Follow-up revisions

RevisionCommit summaryAuthorDate
r22791Merged revisions 22747-22790 via svnmerge from...david09:21, 6 June 2007

Status & tagging log