Escape delimiter in SpecialPage::prefixSearchArray
[lhc/web/wiklou.git] / includes / specialpage / SpecialPage.php
index c062e27..f968276 100644 (file)
@@ -335,6 +335,21 @@ class SpecialPage {
                return array();
        }
 
+       /**
+        * Helper function for implementations of prefixSearchSubpages() that
+        * filter the values in memory (as oppposed to making a query).
+        *
+        * @since 1.24
+        * @param string $search
+        * @param int $limit
+        * @param array $subpages
+        * @return string[]
+        */
+       protected static function prefixSearchArray( $search, $limit, array $subpages ) {
+               $escaped = preg_quote( $search, '/' );
+               return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit );
+       }
+
        /**
         * Sets headers - this should be called from the execute() method of all derived classes!
         */