jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/349425 )
Change subject: HTMLForm: add errors to html in ooui variants ...................................................................... HTMLForm: add errors to html in ooui variants HTMLForm when using OOUI mode was not adding errors to the resulting HTML, if depending on message arrays, as previously used before Status. This exposed additional problems. Aligned the function a bit closer to HTMLForm's getErrorsOrWarnings() Bug: T158492 Change-Id: I8765a025dd441676e35a7c183c67b37036643c1e --- M includes/htmlform/OOUIHTMLForm.php 1 file changed, 9 insertions(+), 13 deletions(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 549edde..6650321 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -191,15 +191,12 @@ * @return string */ public function getErrorsOrWarnings( $elements, $elementsType ) { - if ( !in_array( $elementsType, [ 'error', 'warning' ] ) ) { + if ( !in_array( $elementsType, [ 'error', 'warning' ], true ) ) { throw new DomainException( $elementsType . ' is not a valid type.' ); } - if ( !$elements ) { - $errors = []; - } elseif ( $elements instanceof Status ) { - if ( $elements->isGood() ) { - $errors = []; - } else { + $errors = []; + if ( $elements instanceof Status ) { + if ( !$elements->isGood() ) { $errors = $elements->getErrorsByType( $elementsType ); foreach ( $errors as &$error ) { // Input: [ 'message' => 'foo', 'errors' => [ 'a', 'b', 'c' ] ] @@ -207,13 +204,12 @@ $error = array_merge( [ $error['message'] ], $error['params'] ); } } - } elseif ( $elementsType === 'errors' ) { - $errors = $elements; - if ( !is_array( $errors ) ) { - $errors = [ $errors ]; + } elseif ( $elementsType === 'error' ) { + if ( is_array( $elements ) ) { + $errors = $elements; + } elseif ( is_string( $elements ) ) { + $errors = [ $elements ]; } - } else { - $errors = []; } foreach ( $errors as &$error ) { -- To view, visit https://gerrit.wikimedia.org/r/349425 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8765a025dd441676e35a7c183c67b37036643c1e Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits