Steps to replicate the issue (include links if applicable):
- Set up a wiki using e.g. https://www.mediawiki.org/wiki/Docker/Docker_Hub. Set the language to Chinese (e.g. zh-cn).
- Show debug log by setting any of $wgDebugToolbar, $wgShowDebug or $wgDebugLogFile in LocalSettings.php.
- Open any page.
What happens?:
On every request, lots of logs like this can be seen:
[silenced-error] ... PHP Warning: filemtime(): stat failed for /var/www/html/languages/i18n/zh-cn.json
Although the error is suppressed with AtEase::suppressWarnings in includes/language/dependency/FileDependency.php, the default error handler MWExceptionHandler::handleError still gets invoked nevertheless, since php filemtime always raises E_WARNING when it does not succeed. There is a cost to call the error handler, even though it just throws the log away if not configured to output. I first noticed this when examining Excimer report related to T193472#9790543. Though that bug was resolved, the time used by the error handler is still noticeable.
Chinese languages have complex fallback rules. For zh-cn, the translation file provided is usually zh-hans. Therefore it rarely uses the normal code path that does not involve the error handler.
This does not affect WMF wikis since the localisation cache is manually generated there.
What should have happened instead?:
Maybe some sort of file existence cache (or cache on the last used file for the requested language) can be added, so that it won't trigger the error handler too frequently. Or just document that the default $wgLocalisationCacheConf['manualRecache'] = false should be avoided for wikis using Chinese or other fallback-heavy languages.
Software version: 1.44.0