* @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;
}
/**
$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()