Page MenuHomePhabricator

ListFiles special page filter files
Closed, DuplicatePublicBUG REPORT

Description

Create mediawiki having few files
Go to Special:ListFiles
If search input box type some text from middle of name of some file or from beginning
e.g. if there is "My autumn file.txt" type "autumn"

Result: after pressing button file does not appear in list

MW: 1.35.1

Probale cause: ImageListPager makes some case changes then use LOWER function to do case-insensitive compare.
But img_name is varbinary so case does not change and even LIKE search is case-sensitive.

Proposed fix: convert varbinary to utf8mb4 before calling LOWER, also other php function is needed.

--- ImageListPager.php.orig     2021-10-14 16:31:52.000000000 +0300
+++ ImageListPager.php  2021-10-14 19:32:04.184765179 +0300
@@ -90,9 +90,9 @@

                        if ( $nt ) {
                                $dbr = wfGetDB( DB_REPLICA );
-                               $this->mQueryConds[] = 'LOWER(img_name)' .
+                               $this->mQueryConds[] = 'LOWER(CONVERT(img_name USING utf8mb4))' .
                                        $dbr->buildLike( $dbr->anyString(),
-                                               strtolower( $nt->getDBkey() ), $dbr->anyString() );
+                                               mb_strtolower( $nt->getDBkey() ), $dbr->anyString() );
                        }
                }

@@ -161,9 +161,9 @@
                        $nt = Title::newFromText( $this->mSearch );
                        if ( $nt ) {
                                $dbr = wfGetDB( DB_REPLICA );
-                               $conds[] = 'LOWER(' . $prefix . '_name)' .
+                               $conds[] = 'LOWER(CONVERT(' . $prefix . '_name USING utf8mb4))' .
                                        $dbr->buildLike( $dbr->anyString(),
-                                               strtolower( $nt->getDBkey() ), $dbr->anyString() );
+                                               mb_strtolower( $nt->getDBkey() ), $dbr->anyString() );
                        }
                }