Merge "WebInstaller::setVarsFromRequest() do not trim passwords"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 21 Jul 2014 18:24:36 +0000 (18:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 21 Jul 2014 18:24:36 +0000 (18:24 +0000)
1  2 
includes/installer/WebInstaller.php

@@@ -729,6 -729,16 +729,6 @@@ class WebInstaller extends Installer 
                $this->output->addHTML( $html );
        }
  
 -      /**
 -       * @param Status $status
 -       */
 -      public function showStatusMessage( Status $status ) {
 -              $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
 -              foreach ( $errors as $error ) {
 -                      call_user_func_array( array( $this, 'showMessage' ), $error );
 -              }
 -      }
 -
        /**
         * Label a control by wrapping a config-input div around it and putting a
         * label before it.
         *      var:             The variable to be configured (required)
         *      label:           The message name for the label (required)
         *      itemLabelPrefix: The message name prefix for the item labels (required)
 +       *      itemLabels:      List of message names to use for the item labels instead of itemLabelPrefix, keyed by values
         *      values:          List of allowed values (required)
         *      itemAttribs:     Array of attribute arrays, outer key is the value name (optional)
         *      commonAttribs:   Attribute array applied to all items
         * @return string
         */
        public function getRadioSet( $params ) {
 -              if ( !isset( $params['controlName'] ) ) {
 -                      $params['controlName'] = 'config_' . $params['var'];
 -              }
 -
 -              if ( !isset( $params['value'] ) ) {
 -                      $params['value'] = $this->getVar( $params['var'] );
 -              }
 +              $items = $this->getRadioElements( $params );
  
                if ( !isset( $params['label'] ) ) {
                        $label = '';
                } else {
                        $label = $params['label'];
                }
 +
 +              if ( !isset( $params['controlName'] ) ) {
 +                      $params['controlName'] = 'config_' . $params['var'];
 +              }
 +
                if ( !isset( $params['help'] ) ) {
                        $params['help'] = "";
                }
 +
                $s = "<ul>\n";
 +              foreach ( $items as $value => $item ) {
 +                      $s .= "<li>$item</li>\n";
 +              }
 +              $s .= "</ul>\n";
 +
 +              return $this->label( $label, $params['controlName'], $s, $params['help'] );
 +      }
 +
 +      /**
 +       * Get a set of labelled radio buttons. You probably want to use getRadioSet(), not this.
 +       *
 +       * @see getRadioSet
 +       *
 +       * @return array
 +       */
 +      public function getRadioElements( $params ) {
 +              if ( !isset( $params['controlName'] ) ) {
 +                      $params['controlName'] = 'config_' . $params['var'];
 +              }
 +
 +              if ( !isset( $params['value'] ) ) {
 +                      $params['value'] = $this->getVar( $params['var'] );
 +              }
 +
 +              $items = array();
 +
                foreach ( $params['values'] as $value ) {
                        $itemAttribs = array();
  
                        $itemAttribs['id'] = $id;
                        $itemAttribs['tabindex'] = $this->nextTabIndex();
  
 -                      $s .=
 -                              '<li>' .
 +                      $items[$value] =
                                Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
                                '&#160;' .
                                Xml::tags( 'label', array( 'for' => $id ), $this->parse(
 -                                      wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
 -                              ) ) .
 -                              "</li>\n";
 +                                      isset( $params['itemLabels'] ) ?
 +                                              wfMessage( $params['itemLabels'][$value] )->plain() :
 +                                              wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
 +                              ) );
                }
  
 -              $s .= "</ul>\n";
 -
 -              return $this->label( $label, $params['controlName'], $s, $params['help'] );
 +              return $items;
        }
  
        /**
                $newValues = array();
  
                foreach ( $varNames as $name ) {
-                       $value = trim( $this->request->getVal( $prefix . $name ) );
+                       $value = $this->request->getVal( $prefix . $name );
+                       // bug 30524, do not trim passwords
+                       if ( stripos( $name, 'password' ) === false ) {
+                               $value = trim( $value );
+                       }
                        $newValues[$name] = $value;
  
                        if ( $value === null ) {
                        $path = $_SERVER['SCRIPT_NAME'];
                }
                if ( $path !== false ) {
 -                      $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
 -                      $this->setVar( 'wgScriptPath', $uri );
 +                      $scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
 +                      $scriptExtension = $this->getVar( 'wgScriptExtension' );
 +
 +                      $this->setVar( 'wgScriptPath', "$scriptPath" );
 +                      // Update variables set from Setup.php that are derived from wgScriptPath
 +                      $this->setVar( 'wgScript', "$scriptPath/index$scriptExtension" );
 +                      $this->setVar( 'wgLoadScript', "$scriptPath/load$scriptExtension" );
 +                      $this->setVar( 'wgStylePath', "$scriptPath/skins" );
 +                      $this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
 +                      $this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
 +                      $this->setVar( 'wgUploadPath', "$scriptPath/images" );
 +
                } else {
                        $this->showError( 'config-no-uri' );