r34817 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34816‎ | r34817 | r34818 >
Date:17:29, 14 May 2008
Author:btongminh
Status:old
Tags:
Comment:
* Create ForeignDBFile objects from ForeignDBRepo::findBySha1
* Add foreign duplicates to ImagePage
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignDBFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignDBRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImagePage.php
@@ -639,19 +639,16 @@
640640 global $wgOut, $wgUser;
641641
642642 if ( !( $hash = $this->img->getSha1() ) ) return;
643 - // Should find a proper way to link to foreign files
644 - // Deprecates checkSharedConflict
645 - //$dupes = RepoGroup::singleton()->findBySha1( $hash );
646 - $dupes = RepoGroup::singleton()->getLocalRepo()->findBySha1( $hash );
 643+ // Probably deprecates checkSharedConflict?
 644+ $dupes = RepoGroup::singleton()->findBySha1( $hash );
 645+ //$dupes = RepoGroup::singleton()->getLocalRepo()->findBySha1( $hash );
647646
648647 // Don't dupe with self
649 - $index = 0;
650648 $self = $this->img->getRepoName().':'.$this->img->getName();
651 - foreach ( $dupes as $file ) {
 649+ foreach ( $dupes as $index => $file ) {
652650 $key = $file->getRepoName().':'.$file->getName();
653651 if ( $key == $self )
654652 unset( $dupes[$index] );
655 - $index++;
656653 }
657654 if ( count( $dupes ) == 0 ) return;
658655
@@ -660,7 +657,11 @@
661658
662659 $sk = $wgUser->getSkin();
663660 foreach ( $dupes as $file ) {
664 - $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
 661+ if ( $file->isLocal() )
 662+ $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
 663+ else
 664+ $link = $sk->makeExternalLink( $file->getDescriptionUrl(),
 665+ $file->getTitle()->getPrefixedText() );
665666 $wgOut->addHTML( "<li>{$link}</li>\n" );
666667 }
667668 $wgOut->addHTML( "</ul>\n" );
Index: trunk/phase3/includes/filerepo/ForeignDBFile.php
@@ -5,6 +5,17 @@
66 return new self( $title, $repo );
77 }
88
 9+ /**
 10+ * Create a ForeignDBFile from a title
 11+ * Do not call this except from inside a repo class.
 12+ */
 13+ static function newFromRow( $row, $repo ) {
 14+ $title = Title::makeTitle( NS_IMAGE, $row->img_name );
 15+ $file = new self( $title, $repo );
 16+ $file->loadFromRow( $row );
 17+ return $file;
 18+ }
 19+
920 function getCacheKey() {
1021 if ( $this->repo->hasSharedCache ) {
1122 $hashedName = md5($this->name);
Index: trunk/phase3/includes/filerepo/ForeignDBRepo.php
@@ -13,6 +13,12 @@
1414 var $dbConn;
1515 var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
1616
 17+ function newFileFromRow( $row ) {
 18+ if ( isset( $row->img_name ) )
 19+ return ForeignDBFile::newFromRow( $row, $this );
 20+ return parent::newFileFromRow( $row );
 21+ }
 22+
1723 function __construct( $info ) {
1824 parent::__construct( $info );
1925 $this->dbType = $info['dbType'];

Status & tagging log