jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/352861 )
Change subject: Apply $wgShellLocale in Setup.php ...................................................................... Apply $wgShellLocale in Setup.php While most of MediaWiki ignores the shell's/C library's locale setting, there are some things other than shell execs that use it (e.g. the luasandbox PHP extension). To provide a consistent environment, set the locale in Setup.php instead of letting it be changed mid-request depending on whether something else happened to have called certain functions. Bug: T107128 Change-Id: I02943803d26d5b1b3ac00ef9216f69cdfa149585 --- M RELEASE-NOTES-1.30 M includes/DefaultSettings.php M includes/GlobalFunctions.php M includes/Setup.php 4 files changed, 9 insertions(+), 19 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index e61277a..22fed0c 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -21,6 +21,8 @@ to plain class names, using the 'factory' key in the module description array. This allows dependency injection to be used for ResourceLoader modules. * $wgExceptionHooks has been removed. +* $wgShellLocale is now applied for all requests. wfInitShellLocale() is + deprecated and a no-op, as it is no longer needed. === New features in 1.30 === * (T37247) Output from Parser::parse() will now be wrapped in a div with diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 19c585d..f7f52e5 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -8183,7 +8183,6 @@ * @note If multiple wikis are being served from the same process (e.g. the * same fastCGI or Apache server), this setting must be the same on all those * wikis. - * @see wfInitShellLocale() */ $wgShellLocale = 'C.UTF-8'; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9150338..c6ccf31 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2192,8 +2192,6 @@ * @return string */ function wfEscapeShellArg( /*...*/ ) { - wfInitShellLocale(); - $args = func_get_args(); if ( count( $args ) === 1 && is_array( reset( $args ) ) ) { // If only one argument has been passed, and that argument is an array, @@ -2307,8 +2305,6 @@ $includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr']; $profileMethod = isset( $options['profileMethod'] ) ? $options['profileMethod'] : wfGetCaller(); - - wfInitShellLocale(); $envcmd = ''; foreach ( $environ as $k => $v ) { @@ -2533,25 +2529,14 @@ } /** - * Set the locale for locale-sensitive operations + * Formerly set the locale for locale-sensitive operations * - * Sets LC_ALL to a known value to work around issues like the following: - * - https://bugs.php.net/bug.php?id=45132 escapeshellarg() destroys non-ASCII - * characters if LANG is not a UTF-8 locale - * - T107128 Scribunto string comparison works case insensitive while the - * standard Lua case sensitive + * This is now done in Setup.php. * + * @deprecated since 1.30, no longer needed * @see $wgShellLocale */ function wfInitShellLocale() { - static $done = false; - if ( $done ) { - return; - } - $done = true; - global $wgShellLocale; - putenv( "LC_ALL=$wgShellLocale" ); - setlocale( LC_ALL, $wgShellLocale ); } /** diff --git a/includes/Setup.php b/includes/Setup.php index 5ea96dd..b10cf23 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -49,6 +49,10 @@ mb_internal_encoding( 'UTF-8' ); +// Set the configured locale on all requests for consisteny +putenv( "LC_ALL=$wgShellLocale" ); +setlocale( LC_ALL, $wgShellLocale ); + // Set various default paths sensibly... $ps_default = Profiler::instance()->scopedProfileIn( $fname . '-defaults' ); -- To view, visit https://gerrit.wikimedia.org/r/352861 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I02943803d26d5b1b3ac00ef9216f69cdfa149585 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits