Stop profiling before ending the function
[lhc/web/wiklou.git] / includes / ImagePage.php
index ddb8512..3b8a1f5 100644 (file)
@@ -376,19 +376,21 @@ EOT
        }
 
        function checkSharedConflict() {
-               global $wgOut, $wgUser, $wgUseSharedUploads;
-               if( !$wgUseSharedUploads ) {
+               global $wgOut, $wgUser;
+               $repoGroup = RepoGroup::singleton();
+               if( !$repoGroup->hasForeignRepos() ) {
                        return;
                }
-               if( $this->repo->getName() != 'local' ) {
+               if( !$this->img->isLocal() ) {
                        return;
                }
 
-               $repo = RepoGroup::singleton()->getRepoByName( 'shared' );
-               $dupfile = $repo->newFile( $this->img->getTitle() );
-               if( !$dupfile->exists() ) {
+               $this->dupFile = null;
+               $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
+               
+               if( !$this->dupFile )
                        return;
-               }
+               $dupfile = $this->dupFile;
                $same = (
                        ($this->img->getSha1() == $dupfile->getSha1()) &&
                        ($this->img->getSize() == $dupfile->getSize())
@@ -405,6 +407,13 @@ EOT
                }
        }
 
+       function checkSharedConflictCallback( $repo ) {
+               $dupfile = $repo->newFile( $this->img->getTitle() );
+               if( $dupfile->exists() )
+                       $this->dupFile = $dupfile;
+               return $dupfile->exists();
+       }
+
        function getUploadUrl() {
                $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
                return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );