mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CiteThisPage
synced 2024-11-15 03:33:55 +00:00
Add setFormIdentifier to prevent validation errors
Used the setFormIdentifier to add a additional parameter to the url, allowing prefilled requests to be distinguished and thus preventing validation errors. Also, updated the url parameters at CiteThisPageHooks.php. Bug: T238467 Change-Id: Ic1d0612bb4d4a40bc1ce0588c65782e33c09c3ca
This commit is contained in:
parent
a145b85841
commit
ca97c3fb06
|
@ -19,7 +19,8 @@ class CiteThisPageHooks {
|
|||
$nav_urls['citethispage'] = [
|
||||
'text' => $skintemplate->msg( 'citethispage-link' )->text(),
|
||||
'href' => SpecialPage::getTitleFor( 'CiteThisPage' )
|
||||
->getLocalURL( [ 'page' => $title->getPrefixedDBkey(), 'id' => $revid ] ),
|
||||
->getLocalURL( [ 'page' => $title->getPrefixedDBkey(), 'id' => $revid,
|
||||
'wpFormIdentifier' => 'titleform' ] ),
|
||||
'id' => 't-cite',
|
||||
# Used message keys: 'tooltip-citethispage', 'accesskey-citethispage'
|
||||
'single-id' => 'citethispage',
|
||||
|
|
|
@ -33,6 +33,7 @@ class SpecialCiteThisPage extends FormSpecialPage {
|
|||
|
||||
protected function alterForm( HTMLForm $form ) {
|
||||
$form->setMethod( 'get' );
|
||||
$form->setFormIdentifier( 'titleform' );
|
||||
}
|
||||
|
||||
protected function getFormFields() {
|
||||
|
@ -53,8 +54,7 @@ class SpecialCiteThisPage extends FormSpecialPage {
|
|||
|
||||
public function onSubmit( array $data ) {
|
||||
// GET forms are "submitted" on every view, so check
|
||||
// that some data was put in for page, as empty string
|
||||
// will pass validation
|
||||
// that some data was put in for page
|
||||
if ( strlen( $data['page'] ) ) {
|
||||
$this->title = Title::newFromText( $data['page'] );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue