diff options
author | Func <Funcer@outlook.com> | 2022-03-20 20:06:28 +0800 |
---|---|---|
committer | Func <Funcer@outlook.com> | 2022-03-27 11:51:59 +0800 |
commit | ef2e948d31d9fc57cb208ebbd85a9fc902c6f28d (patch) | |
tree | 7670a72f2e6ebf021def7b9ae5f236b46fdda3c9 /includes/htmlform | |
parent | 96099ac63f4a0c2dd4c3df2b610951ec05c0214b (diff) | |
download | mediawikicore-ef2e948d31d9fc57cb208ebbd85a9fc902c6f28d.tar.gz mediawikicore-ef2e948d31d9fc57cb208ebbd85a9fc902c6f28d.zip |
HTMLForm: Add title field if the action is overridden to script path
Some use cases like HistoryAction prefer the `index.php` form to keep
consistency, so they use setAction( wfScript() ) or something similar.
But the title is missing, so they hack it with manual addHiddenField()
or add a 'title' field in the descriptor. This is not good and prevents
us to warn the use of internal fields (title, wfEditToken).
Bug: T285464
Change-Id: Iaec81a2fb49162f2fc764f143f88e887572a3a0b
Diffstat (limited to 'includes/htmlform')
-rw-r--r-- | includes/htmlform/HTMLForm.php | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 368097318e2e..4fdd1bd62bf0 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -1357,11 +1357,10 @@ class HTMLForm extends ContextSource { $this->getUser()->getEditToken( $this->mTokenSalt ), [ 'id' => 'wpEditToken' ] ) . "\n"; - $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } - - $articlePath = $this->getConfig()->get( 'ArticlePath' ); - if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() === 'get' ) { + if ( $this->getMethod() === 'post' || + $this->getAction() === $this->getConfig()->get( 'Script' ) + ) { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } @@ -2128,10 +2127,10 @@ class HTMLForm extends ContextSource { // Check whether we are in GET mode and the ArticlePath contains a "?" // meaning that getLocalURL() would return something like "index.php?title=...". // As browser remove the query string before submitting GET forms, - // it means that the title would be lost. In such case use wfScript() instead + // it means that the title would be lost. In such case use script path instead // and put title in an hidden field (see getHiddenFields()). if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() === 'get' ) { - return wfScript(); + return $this->getConfig()->get( 'Script' ); } return $this->getTitle()->getLocalURL(); |