jenkins-bot has submitted this change and it was merged.

Change subject: Fixed error in LocalRepo::findFiles()
......................................................................


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
---
M includes/filerepo/LocalRepo.php
1 file changed, 18 insertions(+), 7 deletions(-)

Approvals:
  Brian Wolff: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php
index 1c7fc12..c5346aa 100644
--- a/includes/filerepo/LocalRepo.php
+++ b/includes/filerepo/LocalRepo.php
@@ -275,15 +275,26 @@
                $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] );
+                                       }
                                }
                        }
                };

-- 
To view, visit https://gerrit.wikimedia.org/r/102303
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I657c96c6d06af12866c71df194e18feb9ad53bd9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to