From 648bed9f8394bdc3d87ce4d71ce0539754624529 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 5 May 2011 11:52:23 +0000 Subject: [PATCH] For bug 28738, have the installer check for the Suhosin GET variable length limit and set $wgResourceLoaderMaxQueryLength correspondingly in LocalSettings.php . Of course this only works for new installs, no idea if this can be handled cleanly for upgrades --- includes/installer/Installer.i18n.php | 1 + includes/installer/Installer.php | 19 ++++++++++++++++++- includes/installer/LocalSettingsGenerator.php | 8 +++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 3904e4252e..b21f71c99a 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -155,6 +155,7 @@ Installation aborted.', 'config-using531' => 'MediaWiki cannot be used with PHP $1 due to a bug involving reference parameters to __call(). Upgrade to PHP 5.3.2 or higher, or downgrade to PHP 5.3.0 to resolve this. Installation aborted.', + 'config-suhosin-max-value-length' => "Suhosin is installed and limits the GET parameter length to $1 bytes. MediaWiki's ResourceLoader component will work around this limit, but that will degrade performance. If at all possible, you should set suhosin.get.max_value_length to 1024 or higher in php.ini , and set \$wgResourceLoaderMaxQueryLength to the same value in LocalSettings.php .", 'config-db-type' => 'Database type:', 'config-db-host' => 'Database host:', 'config-db-host-help' => 'If your database server is on different server, enter the host name or IP address here. diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 58ce470fe6..f8de893522 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -103,7 +103,8 @@ abstract class Installer { 'envCheckExtension', 'envCheckShellLocale', 'envCheckUploadsDirectory', - 'envCheckLibicu' + 'envCheckLibicu', + 'envCheckSuhosinMaxValueLength', ); /** @@ -141,6 +142,7 @@ abstract class Installer { 'wgUseInstantCommons', 'wgUpgradeKey', 'wgDefaultSkin', + 'wgResourceLoaderMaxQueryLength', ); /** @@ -966,6 +968,21 @@ abstract class Installer { $this->showMessage( 'config-uploads-not-safe', $dir ); } } + + /** + * Checks if suhosin.get.max_value_length is set, and if so, sets + * $wgResourceLoaderMaxQueryLength to that value in the generated + * LocalSettings file + */ + protected function envCheckSuhosinMaxValueLength() { + $maxValueLength = ini_get( 'suhosin.get.max_value_length' ); + if ( $maxValueLength > 0 ) { + $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength ); + } else { + $maxValueLength = -1; + } + $this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength ); + } /** * Convert a hex string representing a Unicode code point to that code point. diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index db74a28efb..94c84e329d 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -46,7 +46,7 @@ class LocalSettingsGenerator { 'wgRightsText', 'wgRightsCode', 'wgMainCacheType', 'wgEnableUploads', 'wgMainCacheType', '_MemCachedServers', 'wgDBserver', 'wgDBuser', 'wgDBpassword', 'wgUseInstantCommons', 'wgUpgradeKey', 'wgDefaultSkin', - 'wgMetaNamespace' + 'wgMetaNamespace', 'wgResourceLoaderMaxQueryLength' ), $db->getGlobalNames() ); @@ -307,6 +307,12 @@ if ( !defined( 'MEDIAWIKI' ) ) { # Path to the GNU diff3 utility. Used for conflict resolution. \$wgDiff3 = \"{$this->values['wgDiff3']}\"; + +# Query string length limit for ResourceLoader. You should only set this if +# your web server has a query string length limit (then set it to that limit), +# or if you have suhosin.get.max_value_length set in php.ini (then set it to +# that value) +\$wgResourceLoaderMaxQueryLength = {$this->values['wgResourceLoaderMaxQueryLength']}; "; } -- 2.20.1