r82687 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82686‎ | r82687 | r82688 >
Date:17:54, 23 February 2011
Author:demon
Status:deferred
Tags:
Comment:
(bug 25855) Installer does not validate Memcached server settings
Modified paths:
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstallerPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -746,6 +746,52 @@
747747 }
748748
749749 /**
 750+ * Get a labelled textarea to configure a variable
 751+ *
 752+ * @param $params Array
 753+ * Parameters are:
 754+ * var: The variable to be configured (required)
 755+ * label: The message name for the label (required)
 756+ * attribs: Additional attributes for the input element (optional)
 757+ * controlName: The name for the input element (optional)
 758+ * value: The current value of the variable (optional)
 759+ * help: The html for the help text (optional)
 760+ */
 761+ public function getTextArea( $params ) {
 762+ if ( !isset( $params['controlName'] ) ) {
 763+ $params['controlName'] = 'config_' . $params['var'];
 764+ }
 765+
 766+ if ( !isset( $params['value'] ) ) {
 767+ $params['value'] = $this->getVar( $params['var'] );
 768+ }
 769+
 770+ if ( !isset( $params['attribs'] ) ) {
 771+ $params['attribs'] = array();
 772+ }
 773+ if ( !isset( $params['help'] ) ) {
 774+ $params['help'] = "";
 775+ }
 776+ return
 777+ $this->label(
 778+ $params['label'],
 779+ $params['controlName'],
 780+ Xml::textarea(
 781+ $params['controlName'],
 782+ $params['value'],
 783+ 30,
 784+ 5,
 785+ $params['attribs'] + array(
 786+ 'id' => $params['controlName'],
 787+ 'class' => 'config-input-text',
 788+ 'tabindex' => $this->nextTabIndex()
 789+ )
 790+ ),
 791+ $params['help']
 792+ );
 793+ }
 794+
 795+ /**
750796 * Get a labelled password box to configure a variable.
751797 *
752798 * Implements password hiding
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -438,7 +438,14 @@
439439 'config-cache-memcached' => 'Use Memcached (requires additional setup and configuration)',
440440 'config-memcached-servers' => 'Memcached servers:',
441441 'config-memcached-help' => 'List of IP addresses to use for Memcached.
442 -Should be separated with commas and specify the port to be used (for example: 127.0.0.1:11211, 192.168.1.25:11211).',
 442+Should specify one per line and specify the port to be used. For example:
 443+ 127.0.0.1:11211
 444+ 192.168.1.25:1234',
 445+ 'config-memcache-needservers' => 'You selected Memcached as your cache type but did not specify any servers',
 446+ 'config-memcache-badip' => 'You have entered an invalid IP address for Memcached: $1',
 447+ 'config-memcache-noport' => 'You did not specify a port to use for Memcached server: $1.
 448+If you do not know the port, the default is 11211',
 449+ 'config-memcache-badport' => 'Memcached port numbers should be between $1 and $2',
443450 'config-extensions' => 'Extensions',
444451 'config-extensions-help' => 'The extensions listed above were detected in your <code>./extensions</code> directory.
445452
Index: trunk/phase3/includes/installer/WebInstallerPage.php
@@ -867,7 +867,7 @@
868868 ) ) .
869869 $this->parent->getHelpBox( 'config-cache-help' ) .
870870 '<div id="config-memcachewrapper">' .
871 - $this->parent->getTextBox( array(
 871+ $this->parent->getTextArea( array(
872872 'var' => '_MemCachedServers',
873873 'label' => 'config-memcached-servers',
874874 'help' => $this->parent->getHelpBox( 'config-memcached-help' )
@@ -1002,6 +1002,28 @@
10031003 }
10041004 }
10051005 $this->parent->setVar( '_Extensions', $extsToInstall );
 1006+
 1007+ if( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
 1008+ $memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
 1009+ if( !$memcServers ) {
 1010+ $this->parent->showError( 'config-memcache-needservers' );
 1011+ return false;
 1012+ }
 1013+
 1014+ foreach( $memcServers as $server ) {
 1015+ $memcParts = explode( ":", $server );
 1016+ if( !IP::isValid( $memcParts[0] ) ) {
 1017+ $this->parent->showError( 'config-memcache-badip', $memcParts[0] );
 1018+ return false;
 1019+ } elseif( !isset( $memcParts[1] ) ) {
 1020+ $this->parent->showError( 'config-memcache-noport', $memcParts[0] );
 1021+ return false;
 1022+ } elseif( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
 1023+ $this->parent->showError( 'config-memcache-badport', 1, 65535 );
 1024+ return false;
 1025+ }
 1026+ }
 1027+ }
10061028 return true;
10071029 }
10081030

Follow-up revisions

RevisionCommit summaryAuthorDate
r97772* (bug 30041) Fix memcached validation in installer to accept resolvable host...brion00:11, 22 September 2011

Status & tagging log