Index: trunk/phase3/includes/filerepo/ArchivedFile.php |
— | — | @@ -30,12 +30,9 @@ |
31 | 31 | /**#@-*/ |
32 | 32 | |
33 | 33 | function ArchivedFile( $title, $id=0, $key='' ) { |
34 | | - if( !is_object($title) ) { |
35 | | - throw new MWException( 'ArchivedFile constructor given bogus title.' ); |
36 | | - } |
37 | 34 | $this->id = -1; |
38 | | - $this->title = $title; |
39 | | - $this->name = $title->getDBkey(); |
| 35 | + $this->title = false; |
| 36 | + $this->name = false; |
40 | 37 | $this->group = ''; |
41 | 38 | $this->key = ''; |
42 | 39 | $this->size = 0; |
— | — | @@ -51,6 +48,20 @@ |
52 | 49 | $this->timestamp = NULL; |
53 | 50 | $this->deleted = 0; |
54 | 51 | $this->dataLoaded = false; |
| 52 | + |
| 53 | + if( is_object($title) ) { |
| 54 | + $this->title = $title; |
| 55 | + $this->name = $title->getDBkey(); |
| 56 | + } |
| 57 | + |
| 58 | + if ($id) |
| 59 | + $this->id = $id; |
| 60 | + |
| 61 | + if ($key) |
| 62 | + $this->key = $key; |
| 63 | + |
| 64 | + if (!$id && !$key && !is_object($title)) |
| 65 | + throw new MWException( "No specifications provided to ArchivedFile constructor." ); |
55 | 66 | } |
56 | 67 | |
57 | 68 | /** |
— | — | @@ -61,8 +72,19 @@ |
62 | 73 | if ( $this->dataLoaded ) { |
63 | 74 | return true; |
64 | 75 | } |
65 | | - $conds = ($this->id) ? "fa_id = {$this->id}" : "fa_storage_key = '{$this->key}'"; |
66 | | - if( $this->title->getNamespace() == NS_IMAGE ) { |
| 76 | + $conds = array(); |
| 77 | + |
| 78 | + if ($this->id>0) |
| 79 | + $conds['fa_id'] = $this->id; |
| 80 | + if ($this->key) |
| 81 | + $conds['fa_storage_key'] = $this->key; |
| 82 | + if ($this->title) |
| 83 | + $conds['fa_name'] = $this->title->getDBkey(); |
| 84 | + |
| 85 | + if (!count($conds)) |
| 86 | + throw new MWException( "No specific information for retrieving archived file" ); |
| 87 | + |
| 88 | + if( !$this->title || $this->title->getNamespace() == NS_IMAGE ) { |
67 | 89 | $dbr = wfGetDB( DB_SLAVE ); |
68 | 90 | $res = $dbr->select( 'filearchive', |
69 | 91 | array( |
— | — | @@ -84,9 +106,7 @@ |
85 | 107 | 'fa_user_text', |
86 | 108 | 'fa_timestamp', |
87 | 109 | 'fa_deleted' ), |
88 | | - array( |
89 | | - 'fa_name' => $this->title->getDBkey(), |
90 | | - $conds ), |
| 110 | + $conds, |
91 | 111 | __METHOD__, |
92 | 112 | array( 'ORDER BY' => 'fa_timestamp DESC' ) ); |
93 | 113 | |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -538,7 +538,7 @@ |
539 | 539 | $warning .= self::getExistsWarning( $this->mLocalFile ); |
540 | 540 | } |
541 | 541 | |
542 | | - $warning .= $this->getDupeWarning( $this->mTempPath ); |
| 542 | + $warning .= $this->getDupeWarning( $this->mTempPath, $finalExt ); |
543 | 543 | |
544 | 544 | if( $warning != '' ) { |
545 | 545 | /** |
— | — | @@ -745,9 +745,10 @@ |
746 | 746 | * Check for duplicate files and throw up a warning before the upload |
747 | 747 | * completes. |
748 | 748 | */ |
749 | | - function getDupeWarning( $tempfile ) { |
| 749 | + function getDupeWarning( $tempfile, $extension ) { |
750 | 750 | $hash = File::sha1Base36( $tempfile ); |
751 | 751 | $dupes = RepoGroup::singleton()->findBySha1( $hash ); |
| 752 | + $archivedImage = new ArchivedFile( null, 0, $hash.".$extension" ); |
752 | 753 | if( $dupes ) { |
753 | 754 | global $wgOut; |
754 | 755 | $msg = "<gallery>"; |
— | — | @@ -761,8 +762,12 @@ |
762 | 763 | wfMsgExt( "file-exists-duplicate", array( "parse" ), count( $dupes ) ) . |
763 | 764 | $wgOut->parse( $msg ) . |
764 | 765 | "</li>\n"; |
| 766 | + } elseif ( $archivedImage->getID() > 0 ) { |
| 767 | + global $wgOut; |
| 768 | + $name = Title::makeTitle( NS_IMAGE, $archivedImage->getName() )->getPrefixedText(); |
| 769 | + return Xml::tags( 'li', null, wfMsgExt( 'file-deleted-duplicate', array( 'parseinline' ), array( $name ) ) ); |
765 | 770 | } else { |
766 | | - return ''; |
| 771 | + return 'FOOO'; |
767 | 772 | } |
768 | 773 | } |
769 | 774 | |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1826,6 +1826,7 @@ |
1827 | 1827 | 'fileexists-shared-forbidden' => 'A file with this name exists already in the shared file repository. |
1828 | 1828 | If you still want to upload your file, please go back and use a new name. [[Image:$1|thumb|center|$1]]', |
1829 | 1829 | 'file-exists-duplicate' => 'This file is a duplicate of the following {{PLURAL:$1|file|files}}:', |
| 1830 | +'file-deleted-duplicate' => "A file identical to this file ([[$1]]) has previously been deleted. You should check that file's deletion history before proceeding to re-upload it.", |
1830 | 1831 | 'successfulupload' => 'Successful upload', |
1831 | 1832 | 'uploadwarning' => 'Upload warning', |
1832 | 1833 | 'savefile' => 'Save file', |