Steps to replicate the issue (include links if applicable):
pi@raspberrypi /v/l/mediawiki> php maintenance/grep.php installed Main_Page:1:<strong>MediaWiki has been installed.</strong> pi@raspberrypi /v/l/mediawiki> php maintenance/grep.php '/installed/i' PHP Warning: preg_match(): No ending delimiter '/' found in /var/lib/mediawiki/maintenance/grep.php on line 83 PHP Warning: preg_match(): No ending delimiter '/' found in /var/lib/mediawiki/maintenance/grep.php on line 83 PHP Warning: preg_match(): No ending delimiter '/' found in /var/lib/mediawiki/maintenance/grep.php on line 83 PHP Warning: preg_match(): No ending delimiter '/' found in /var/lib/mediawiki/maintenance/grep.php on line 83 PHP Warning: preg_match(): No ending delimiter '/' found in /var/lib/mediawiki/maintenance/grep.php on line 83 ...
What should have happened instead?:
It should have matched the same page as it did without the regex markup, and not printed one PHP warning per wikipage.
Software version (skip for WMF-hosted wikis like Wikipedia): 1.38.4
but also in 1.42:
https://github.com/wikimedia/mediawiki/blob/wmf/1.42.0-wmf.25/maintenance/grep.php#L57
https://github.com/wikimedia/mediawiki/blob/master/maintenance/grep.php#L57
Other information (browser name/version, screenshots, etc.):
Essentially this can be fixed by deleting the index inside the first if block:
if ( ( $regex[0] ?? '' ) === '/' ) { $delimRegex = $regex[0]; } else { $delimRegex = '{' . $regex . '}'; }
to:
if ( ( $regex[0] ?? '' ) === '/' ) { $delimRegex = $regex; } else { $delimRegex = '{' . $regex . '}'; }
Workaround:
Use inline flags to set mode in regular expression, such as (?i) for case insensitive search.