Merge "registration: Only allow one extension to set a specific config setting"
[lhc/web/wiklou.git] / includes / htmlform / fields / HTMLRestrictionsField.php
index 5a18025..0310dd0 100644 (file)
@@ -38,7 +38,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField {
                }
 
                $value = rtrim( $request->getText( $this->mName ), "\r\n" );
-               $ips = $value === '' ? [] : explode( PHP_EOL, $value );
+               $ips = $value === '' ? [] : explode( "\n", $value );
                try {
                        return MWRestrictions::newFromArray( [ 'IPAddresses' => $ips ] );
                } catch ( InvalidArgumentException $e ) {
@@ -61,7 +61,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField {
         * @param string|MWRestrictions $value The value the field was submitted with
         * @param array $alldata The data collected from the form
         *
-        * @return bool|string True on success, or String error to display, or
+        * @return bool|string|Message True on success, or String/Message error to display, or
         *   false to fail validation without displaying an error.
         */
        public function validate( $value, $alldata ) {
@@ -73,13 +73,13 @@ class HTMLRestrictionsField extends HTMLTextAreaField {
                        isset( $this->mParams['required'] ) && $this->mParams['required'] !== false
                        && $value instanceof MWRestrictions && !$value->toArray()['IPAddresses']
                ) {
-                       return $this->msg( 'htmlform-required' )->parse();
+                       return $this->msg( 'htmlform-required' );
                }
 
                if ( is_string( $value ) ) {
                        // MWRestrictions::newFromArray failed; one of the IP ranges must be invalid
                        $status = Status::newGood();
-                       foreach ( explode( PHP_EOL,  $value ) as $range ) {
+                       foreach ( explode( "\n",  $value ) as $range ) {
                                if ( !\IP::isIPAddress( $range ) ) {
                                        $status->fatal( 'restrictionsfield-badip', $range );
                                }
@@ -87,7 +87,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField {
                        if ( $status->isOK() ) {
                                $status->fatal( 'unknown-error' );
                        }
-                       return $status->getMessage()->parse();
+                       return $status->getMessage();
                }
 
                if ( isset( $this->mValidationCallback ) ) {
@@ -103,7 +103,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField {
         */
        public function getInputHTML( $value ) {
                if ( $value instanceof MWRestrictions ) {
-                       $value = implode( PHP_EOL, $value->toArray()['IPAddresses'] );
+                       $value = implode( "\n", $value->toArray()['IPAddresses'] );
                }
                return parent::getInputHTML( $value );
        }
@@ -114,7 +114,7 @@ class HTMLRestrictionsField extends HTMLTextAreaField {
         */
        public function getInputOOUI( $value ) {
                if ( $value instanceof MWRestrictions ) {
-                       $value = implode( PHP_EOL, $value->toArray()['IPAddresses'] );
+                       $value = implode( "\n", $value->toArray()['IPAddresses'] );
                }
                return parent::getInputOOUI( $value );
        }