From: Chad Horohoe Date: Fri, 21 Nov 2008 00:18:47 +0000 (+0000) Subject: Add experimental findBySha1 functionality for ForeignAPIRepo. X-Git-Tag: 1.31.0-rc.0~44244 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=41fbb1c897d87e3907f0374c54d88418bfaada2b;p=lhc%2Fweb%2Fwiklou.git Add experimental findBySha1 functionality for ForeignAPIRepo. --- diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 42085a74b7..5f9e609022 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -72,9 +72,8 @@ class ForeignAPIRepo extends FileRepo { array_merge( $query, array( 'format' => 'json', - 'action' => 'query', - 'prop' => 'imageinfo' ) ) ); - + 'action' => 'query' ) ) ); + if( !isset( $this->mQueryCache[$url] ) ) { $key = wfMemcKey( 'ForeignAPIRepo', 'Metadata', md5( $url ) ); $data = $wgMemc->get( $key ); @@ -95,9 +94,24 @@ class ForeignAPIRepo extends FileRepo { function getImageInfo( $title, $time = false ) { return $this->queryImage( array( 'titles' => MWNamespace::getCanonicalName( NS_IMAGE ) . ':' . $title->getText(), - 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime' ) ); + 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime', + 'prop' => 'imageinfo' ) ); } + function findBySha1( $hash ) { + $results = $this->fetchImageQuery( array( + 'aisha1base36' => $hash, + 'aiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime', + 'list' => 'allimages', ) ); + $ret = array(); + foreach ( $results['query']['allimages'] as $img ) { + $ret[] = new ForeignAPIFile( Title::makeTitle( NS_IMAGE, $img['name'] ), $this, $result ); + } + return $ret; + } + + + function getThumbUrl( $name, $width=-1, $height=-1 ) { $info = $this->queryImage( array( 'titles' => 'Image:' . $name,