Merge "Do not require titles on Special:ComparePages"
[lhc/web/wiklou.git] / includes / htmlform / HTMLForm.php
index 6b2afe1..e72faa0 100644 (file)
@@ -50,6 +50,9 @@ use Wikimedia\ObjectFactory;
  *                             if 'class' is not specified, this is used as a map
  *                             through HTMLForm::$typeMappings to get the class name.
  *    'default'             -- default value when the form is displayed
+ *    'nodata'              -- if set (to any value, which casts to true), the data
+ *                             for this field will not be loaded from the actual request. Instead,
+ *                             always the default data is set as the value of this field.
  *    'id'                  -- HTML id attribute
  *    'cssclass'            -- CSS class
  *    'csshelpclass'        -- CSS class used to style help text
@@ -330,9 +333,7 @@ class HTMLForm extends ContextSource {
                $this->mFlatFields = [];
 
                foreach ( $descriptor as $fieldname => $info ) {
-                       $section = isset( $info['section'] )
-                               ? $info['section']
-                               : '';
+                       $section = $info['section'] ?? '';
 
                        if ( isset( $info['type'] ) && $info['type'] === 'file' ) {
                                $this->mUseMultipart = true;
@@ -606,7 +607,7 @@ class HTMLForm extends ContextSource {
                $hoistedErrors = Status::newGood();
                if ( $this->mValidationErrorMessage ) {
                        foreach ( (array)$this->mValidationErrorMessage as $error ) {
-                               call_user_func_array( [ $hoistedErrors, 'fatal' ], $error );
+                               $hoistedErrors->fatal( ...$error );
                        }
                } else {
                        $hoistedErrors->fatal( 'htmlform-invalid-input' );
@@ -802,7 +803,7 @@ class HTMLForm extends ContextSource {
                if ( $section === null ) {
                        return $this->mHeader;
                } else {
-                       return isset( $this->mSectionHeaders[$section] ) ? $this->mSectionHeaders[$section] : '';
+                       return $this->mSectionHeaders[$section] ?? '';
                }
        }
 
@@ -857,7 +858,7 @@ class HTMLForm extends ContextSource {
                if ( $section === null ) {
                        return $this->mFooter;
                } else {
-                       return isset( $this->mSectionFooters[$section] ) ? $this->mSectionFooters[$section] : '';
+                       return $this->mSectionFooters[$section] ?? '';
                }
        }
 
@@ -956,8 +957,8 @@ class HTMLForm extends ContextSource {
                        $data = [
                                'name' => $args[0],
                                'value' => $args[1],
-                               'id' => isset( $args[2] ) ? $args[2] : null,
-                               'attribs' => isset( $args[3] ) ? $args[3] : null,
+                               'id' => $args[2] ?? null,
+                               'attribs' => $args[3] ?? null,
                        ];
                } else {
                        if ( !isset( $data['name'] ) ) {