X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ffilerepo%2FLocalRepo.php;h=8e3355c8c6147ee2efb3654146fbbc31599894e9;hb=4e9300e2beb07c40f0c7d5f63323c498a0331800;hp=bb65b0ad896446372b2801ce98124e5939787a3a;hpb=f7ead5d3ca0e1ae673752f6c6118297bf47e1c88;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index bb65b0ad89..8e3355c8c6 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -180,7 +180,11 @@ class LocalRepo extends FileRepo { * @return string */ public static function getHashFromKey( $key ) { - return strtok( $key, '.' ); + $sha1 = strtok( $key, '.' ); + if ( is_string( $sha1 ) && strlen( $sha1 ) === 32 && $sha1[0] === '0' ) { + $sha1 = substr( $sha1, 1 ); + } + return $sha1; } /** @@ -209,20 +213,16 @@ class LocalRepo extends FileRepo { $setOpts += Database::getCacheSetOptions( $dbr ); - if ( $title instanceof Title ) { - $row = $dbr->selectRow( - [ 'page', 'redirect' ], - [ 'rd_namespace', 'rd_title' ], - [ - 'page_namespace' => $title->getNamespace(), - 'page_title' => $title->getDBkey(), - 'rd_from = page_id' - ], - $method - ); - } else { - $row = false; - } + $row = $dbr->selectRow( + [ 'page', 'redirect' ], + [ 'rd_namespace', 'rd_title' ], + [ + 'page_namespace' => $title->getNamespace(), + 'page_title' => $title->getDBkey(), + 'rd_from = page_id' + ], + $method + ); return ( $row && $row->rd_namespace == NS_FILE ) ? Title::makeTitle( $row->rd_namespace, $row->rd_title )->getDBkey()