r41532 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41531‎ | r41532 | r41533 >
Date:08:13, 2 October 2008
Author:tstarling
Status:old
Tags:
Comment:
* Merged r41379 and r41380: LC_CTYPE configurability and detection.
* Fixed RELEASE-NOTES
* Fixed svn:mergeinfo properties
Modified paths:
  • /branches/REL1_13/phase3 (modified) (history)
  • /branches/REL1_13/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_13/phase3/config/index.php (modified) (history)
  • /branches/REL1_13/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/REL1_13/phase3/includes/GlobalFunctions.php (modified) (history)
  • /branches/REL1_13/phase3/includes/Setup.php (modified) (history)
  • /branches/REL1_13/phase3/skins/common/images/cyrl (modified) (history)
  • /branches/REL1_13/phase3/skins/common/images/cyrl/button_link.png (modified) (history)

Diff [purge]

Property changes on: branches/REL1_13/phase3/skins/common/images/cyrl/button_link.png
___________________________________________________________________
Name: svn:mergeinfo
11 -
Property changes on: branches/REL1_13/phase3/skins/common/images/cyrl
___________________________________________________________________
Name: svn:mergeinfo
22 -
Index: branches/REL1_13/phase3/includes/GlobalFunctions.php
@@ -1074,9 +1074,14 @@
10751075 /**
10761076 * Windows-compatible version of escapeshellarg()
10771077 * Windows doesn't recognise single-quotes in the shell, but the escapeshellarg()
1078 - * function puts single quotes in regardless of OS
 1078+ * function puts single quotes in regardless of OS.
 1079+ *
 1080+ * Also fixes the locale problems on Linux in PHP 5.2.6+ (bug backported to
 1081+ * earlier distro releases of PHP)
10791082 */
10801083 function wfEscapeShellArg( ) {
 1084+ wfInitShellLocale();
 1085+
10811086 $args = func_get_args();
10821087 $first = true;
10831088 $retVal = '';
@@ -2000,6 +2005,7 @@
20012006 $retval = 1;
20022007 return "Unable to run external programs in safe mode.";
20032008 }
 2009+ wfInitShellLocale();
20042010
20052011 if ( php_uname( 's' ) == 'Linux' ) {
20062012 $time = intval( ini_get( 'max_execution_time' ) );
@@ -2025,7 +2031,21 @@
20262032 $output = ob_get_contents();
20272033 ob_end_clean();
20282034 return $output;
 2035+}
20292036
 2037+/**
 2038+ * Workaround for http://bugs.php.net/bug.php?id=45132
 2039+ * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale
 2040+ */
 2041+function wfInitShellLocale() {
 2042+ static $done = false;
 2043+ if ( $done ) return;
 2044+ $done = true;
 2045+ global $wgShellLocale;
 2046+ if ( !wfIniGetBool( 'safe_mode' ) ) {
 2047+ putenv( "LC_CTYPE=$wgShellLocale" );
 2048+ setlocale( LC_CTYPE, $wgShellLocale );
 2049+ }
20302050 }
20312051
20322052 /**
Index: branches/REL1_13/phase3/includes/Setup.php
@@ -113,14 +113,6 @@
114114 );
115115 }
116116 }
117 -
118 -/**
119 - * Workaround for http://bugs.php.net/bug.php?id=45132
120 - * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale
121 - */
122 -putenv( 'LC_CTYPE=en_US.UTF-8' );
123 -setlocale( LC_CTYPE, 'en_US.UTF-8' );
124 -
125117 if ( !class_exists( 'AutoLoader' ) ) {
126118 require_once( "$IP/includes/AutoLoader.php" );
127119 }
Index: branches/REL1_13/phase3/includes/DefaultSettings.php
@@ -778,6 +778,13 @@
779779 $wgEditEncoding = '';
780780
781781 /**
 782+ * Locale for LC_CTYPE, to work around http://bugs.php.net/bug.php?id=45132
 783+ * For Unix-like operating systems, set this to to a locale that has a UTF-8
 784+ * character set. Only the character set is relevant.
 785+ */
 786+$wgShellLocale = 'en_US.utf8';
 787+
 788+/**
782789 * Set this to eg 'ISO-8859-1' to perform character set
783790 * conversion when loading old revisions not marked with
784791 * "utf-8" flag. Use this when converting wiki to UTF-8
Index: branches/REL1_13/phase3/config/index.php
@@ -598,7 +598,6 @@
599599 $conf->RootPW = importPost( "RootPW", "" );
600600 $useRoot = importCheck( 'useroot', false );
601601 $conf->LanguageCode = importPost( "LanguageCode", "en" );
602 -
603602 ## MySQL specific:
604603 $conf->DBprefix = importPost( "DBprefix" );
605604 $conf->setSchema(
@@ -617,6 +616,7 @@
618617 // We need a second field so it doesn't overwrite the MySQL one
619618 $conf->DBprefix2 = importPost( "DBprefix2" );
620619
 620+ $conf->ShellLocale = getShellLocale( $conf->LanguageCode );
621621
622622 /* Check for validity */
623623 $errs = array();
@@ -1521,6 +1521,13 @@
15221522 $rights = ($conf->RightsUrl) ? "" : "# ";
15231523 $hashedUploads = $conf->safeMode ? '' : '# ';
15241524
 1525+ if ( $conf->ShellLocale ) {
 1526+ $locale = '';
 1527+ } else {
 1528+ $locale = '# ';
 1529+ $conf->ShellLocale = 'en_US.UTF-8';
 1530+ }
 1531+
15251532 switch ( $conf->Shm ) {
15261533 case 'memcached':
15271534 $cacheType = 'CACHE_MEMCACHED';
@@ -1692,6 +1699,11 @@
16931700 {$magic}\$wgUseImageMagick = true;
16941701 {$magic}\$wgImageMagickConvertCommand = \"{$convert}\";
16951702
 1703+## If you use ImageMagick (or any other shell command) on a
 1704+## Linux server, this will need to be set to the name of an
 1705+## available UTF-8 locale
 1706+{$locale}\$wgShellLocale = \"{$slconf['ShellLocale']}\";
 1707+
16961708 ## If you want to use image uploads under safe mode,
16971709 ## create the directories images/archive, images/thumb and
16981710 ## images/temp, and make them all writable. Then uncomment
@@ -1934,6 +1946,71 @@
19351947 print "<li>$item</li>";
19361948 }
19371949
 1950+# Determine a suitable value for $wgShellLocale
 1951+function getShellLocale( $wikiLanguage ) {
 1952+ # Give up now if we're in safe mode or open_basedir
 1953+ # It's theoretically possible but tricky to work with
 1954+ if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) ) {
 1955+ return false;
 1956+ }
 1957+
 1958+ $os = php_uname( 's' );
 1959+ $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
 1960+ if ( !in_array( $os, $supported ) ) {
 1961+ return false;
 1962+ }
 1963+
 1964+ # Get a list of available locales
 1965+ $lines = $ret = false;
 1966+ exec( '/usr/bin/locale -a', $lines, $ret );
 1967+ if ( $ret ) {
 1968+ return false;
 1969+ }
 1970+
 1971+ $lines = array_map( 'trim', $lines );
 1972+ $candidatesByLocale = array();
 1973+ $candidatesByLang = array();
 1974+ foreach ( $lines as $line ) {
 1975+ if ( $line === '' ) {
 1976+ continue;
 1977+ }
 1978+ if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
 1979+ continue;
 1980+ }
 1981+ list( $all, $lang, $territory, $charset, $modifier ) = $m;
 1982+ $candidatesByLocale[$m[0]] = $m;
 1983+ $candidatesByLang[$lang][] = $m;
 1984+ }
 1985+
 1986+ # Try the current value of LANG
 1987+ if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
 1988+ return getenv( 'LANG' );
 1989+ }
 1990+
 1991+ # Try the most common ones
 1992+ $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
 1993+ foreach ( $commonLocales as $commonLocale ) {
 1994+ if ( isset( $candidatesByLocale[$commonLocale] ) ) {
 1995+ return $commonLocale;
 1996+ }
 1997+ }
 1998+
 1999+ # Is there an available locale in the Wiki's language?
 2000+ if ( isset( $candidatesByLang[$wikiLang] ) ) {
 2001+ $m = reset( $candidatesByLang[$wikiLang] );
 2002+ return $m[0];
 2003+ }
 2004+
 2005+ # Are there any at all?
 2006+ if ( count( $candidatesByLocale ) ) {
 2007+ $m = reset( $candidatesByLocale );
 2008+ return $m[0];
 2009+ }
 2010+
 2011+ # Give up
 2012+ return false;
 2013+}
 2014+
19382015 ?>
19392016
19402017 <div class="license">
Index: branches/REL1_13/phase3/RELEASE-NOTES
@@ -4,13 +4,9 @@
55 setting since version 1.2.0. If you have it on, turn it *off* if you can.
66
77 == MediaWiki 1.13.2 ==
8 -* Security: Work around misconfiguration by requiring strict comparisons for
9 - in_array in User::isAllowed().
108
11 -== MediaWiki 1.13.1 ==
 9+October 2, 2008
1210
13 -September 6, 2008
14 -
1511 This is a bugfix release of the Summer 2008 snapshot release of MediaWiki.
1612
1713 MediaWiki is now using a "continuous integration" development model with
@@ -24,6 +20,13 @@
2521 Those wishing to use the latest code instead of a branch release can obtain
2622 it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
2723
 24+== Changes since 1.13.1 ==
 25+
 26+* Security: Work around misconfiguration by requiring strict comparisons for
 27+ in_array in User::isAllowed().
 28+* (bug 14944) Detection of an appropriate locale to use for LC_CTYPE during
 29+ shell invocation. For servers that don't have en_US.UTF-8.
 30+
2831 == Changes since 1.13.0
2932
3033 * (bug 15460) Fixed intermittent deadlock errors and poor concurrent
Property changes on: branches/REL1_13/phase3
___________________________________________________________________
Name: svn:mergeinfo
3134 + /trunk/phase3:41379-41380

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41379Proposed fix for bug 14944, specifically the reports that some servers do not...tstarling10:19, 29 September 2008
r41380Added support for LC_CTYPE on SunOS and HP-UX, thanks to River for testing th...tstarling10:53, 29 September 2008

Status & tagging log