Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -103,6 +103,7 @@ |
104 | 104 | action=login |
105 | 105 | * (bug 29237) add interwiki target url attribute to api/query/interwiki |
106 | 106 | * (bug 28392) mark action=undelete×tamps as type "timestamp" |
| 107 | +* (bug 21346) Make deleted images searchable by hash (disabled in Miser Mode) |
107 | 108 | |
108 | 109 | === Languages updated in 1.19 === |
109 | 110 | |
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php |
— | — | @@ -85,6 +85,25 @@ |
86 | 86 | $this->addWhere( 'fa_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); |
87 | 87 | } |
88 | 88 | |
| 89 | + $sha1Set = isset( $params['sha1'] ); |
| 90 | + $sha1base36Set = isset( $params['sha1base36'] ); |
| 91 | + if ( $sha1Set || $sha1base36Set ) { |
| 92 | + global $wgMiserMode; |
| 93 | + if ( $wgMiserMode ) { |
| 94 | + $this->dieUsage( 'Search by hash disabled in Miser Mode', 'hashsearchdisabled' ); |
| 95 | + } |
| 96 | + |
| 97 | + $sha1 = false; |
| 98 | + if ( $sha1Set ) { |
| 99 | + $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 ); |
| 100 | + } elseif ( $sha1base36Set ) { |
| 101 | + $sha1 = $params['sha1base36']; |
| 102 | + } |
| 103 | + if ( $sha1 ) { |
| 104 | + $this->addWhere( 'fa_storage_key=' . $db->addQuotes( $sha1 ) ); |
| 105 | + } |
| 106 | + } |
| 107 | + |
89 | 108 | if ( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
90 | 109 | // Filter out revisions that the user is not allowed to see. There |
91 | 110 | // is no way to indicate that we have skipped stuff because the |
— | — | @@ -201,6 +220,8 @@ |
202 | 221 | 'descending' |
203 | 222 | ) |
204 | 223 | ), |
| 224 | + 'sha1' => null, |
| 225 | + 'sha1base36' => null, |
205 | 226 | 'prop' => array( |
206 | 227 | ApiBase::PARAM_DFLT => 'timestamp', |
207 | 228 | ApiBase::PARAM_ISMULTI => true, |
— | — | @@ -227,6 +248,8 @@ |
228 | 249 | 'prefix' => 'Search for all image titles that begin with this value', |
229 | 250 | 'dir' => 'The direction in which to list', |
230 | 251 | 'limit' => 'How many images to return in total', |
| 252 | + 'sha1' => "SHA1 hash of image. Overrides {$this->getModulePrefix()}sha1base36. Disabled in Miser Mode", |
| 253 | + 'sha1base36' => 'SHA1 hash of image in base 36 (used in MediaWiki). Disabled in Miser Mode', |
231 | 254 | 'prop' => array( |
232 | 255 | 'What image information to get:', |
233 | 256 | ' sha1 - Adds SHA-1 hash for the image', |
— | — | @@ -250,6 +273,7 @@ |
251 | 274 | public function getPossibleErrors() { |
252 | 275 | return array_merge( parent::getPossibleErrors(), array( |
253 | 276 | array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted file information' ), |
| 277 | + array( 'code' => 'hashsearchdisabled', 'info' => 'Search by hash disabled in Miser Mode' ), |
254 | 278 | ) ); |
255 | 279 | } |
256 | 280 | |