From ba4a09d209ba6f4b7e169ea46c551c5cdf12df5d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 17 Dec 2013 13:09:21 -0800 Subject: [PATCH] Fixed error in LocalRepo::findFiles() * This occured if the client wiki did not capitalize, and the repo did, and a file was searched under the un-capitized name. bug: 58587 Change-Id: I657c96c6d06af12866c71df194e18feb9ad53bd9 --- includes/filerepo/LocalRepo.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 1c7fc129ad..c5346aa1c4 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -275,15 +275,26 @@ class LocalRepo extends FileRepo { $applyMatchingFiles = function( ResultWrapper $res, &$searchSet, &$finalFiles ) use ( $repo, $fileMatchesSearch, $flags ) { + global $wgContLang; + $info = $repo->getInfo(); foreach ( $res as $row ) { $file = $repo->newFileFromRow( $row ); - $dbKey = $file->getTitle()->getDBkey(); - // There must have been a search for this exact DB Key - if ( isset( $searchSet[$dbKey] ) && $fileMatchesSearch( $file, $searchSet[$dbKey] ) ) { - $finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY ) - ? array( 'title' => $dbKey, 'timestamp' => $file->getTimestamp() ) - : $file; - unset( $searchSet[$dbKey] ); + // There must have been a search for this DB key, but this has to handle the + // cases were title capitalization is different on the client and repo wikis. + $dbKeysLook = array( str_replace( ' ', '_', $file->getName() ) ); + if ( !empty( $info['initialCapital'] ) ) { + // Search keys for "hi.png" and "Hi.png" should use the "Hi.png file" + $dbKeysLook[] = $wgContLang->lcfirst( $file->getName() ); + } + foreach ( $dbKeysLook as $dbKey ) { + if ( isset( $searchSet[$dbKey]) + && $fileMatchesSearch( $file, $searchSet[$dbKey] ) + ) { + $finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY ) + ? array( 'title' => $dbKey, 'timestamp' => $file->getTimestamp() ) + : $file; + unset( $searchSet[$dbKey] ); + } } } }; -- 2.20.1