From: Lucas Werkmeister Date: Tue, 19 Mar 2019 14:19:30 +0000 (+0100) Subject: Fix invalid HTMLForm::setValidationErrorMessage doc X-Git-Tag: 1.34.0-rc.0~2347^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=5d46ab1453c26535413feb305b04059ad5929abd;hp=5612194879bd4f5c7d3e7c75d42b08bf91b84428;p=lhc%2Fweb%2Fwiklou.git Fix invalid HTMLForm::setValidationErrorMessage doc The method has not actually supported scalar or single-level array arguments for a while now; according to Michael Große, this ability was lost in Ibb17bb61ac. No one seems to have noticed (indeed, MediaWiki code search finds no callers at all [1]), so instead of trying to fix it, let’s just update the documentation. We can also remove a cast to array in trySubmit(), because if the value wasn’t already an array, then converting it to a single-element array and then trying to spread its only element into $hoistedErrors->fatal() arguments still fails (“only arrays and Traversables can be unpacked”). [1]: https://codesearch.wmflabs.org/search/?q=setValidationErrorMessage Change-Id: I8c292ec62ef4aec89217e86a75d7f2e88111f43f --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 82cbb40d0c..ee0da7b64f 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -605,7 +605,7 @@ class HTMLForm extends ContextSource { $valid = true; $hoistedErrors = Status::newGood(); if ( $this->mValidationErrorMessage ) { - foreach ( (array)$this->mValidationErrorMessage as $error ) { + foreach ( $this->mValidationErrorMessage as $error ) { $hoistedErrors->fatal( ...$error ); } } else { @@ -700,8 +700,8 @@ class HTMLForm extends ContextSource { /** * Set a message to display on a validation error. * - * @param string|array $msg String or Array of valid inputs to wfMessage() - * (so each entry can be either a String or Array) + * @param array $msg Array of valid inputs to wfMessage() + * (so each entry must itself be an array of arguments) * * @return HTMLForm $this for chaining calls (since 1.20) */