Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/362254 )

Change subject: Switch all forms to POST
......................................................................

Switch all forms to POST

Bug: T169251
Change-Id: Icbe6724e155a608b6122ad1b421251c0958aeb64
---
M src/Html/ChangeTitleForm.php
M src/Html/ImportPreviewPage.php
M src/Html/InputFormPage.php
M src/SpecialImportFile.php
4 files changed, 20 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter 
refs/changes/54/362254/1

diff --git a/src/Html/ChangeTitleForm.php b/src/Html/ChangeTitleForm.php
index b229bd5..c06232b 100644
--- a/src/Html/ChangeTitleForm.php
+++ b/src/Html/ChangeTitleForm.php
@@ -38,7 +38,7 @@
                        'form',
                        [
                                'action' => 
$this->specialPage->getPageTitle()->getLocalURL(),
-                               'method' => 'GET',
+                               'method' => 'POST',
                        ]
                ) .
                Html::element(
diff --git a/src/Html/ImportPreviewPage.php b/src/Html/ImportPreviewPage.php
index d5b36d3..8cf586a 100644
--- a/src/Html/ImportPreviewPage.php
+++ b/src/Html/ImportPreviewPage.php
@@ -80,7 +80,7 @@
                                [
                                        'class' => 'mw-importfile-rightAlign',
                                        'action' => 
$this->specialPage->getPageTitle()->getLocalURL(),
-                                       'method' => 'GET',
+                                       'method' => 'POST',
                                ]
                        ) .
                        Html::element(
@@ -122,7 +122,7 @@
                                [
                                        'class' => 'mw-importfile-rightAlign',
                                        'action' => 
$this->specialPage->getPageTitle()->getLocalURL(),
-                                       'method' => 'GET',
+                                       'method' => 'POST',
                                ]
                        ) .
                        Html::element(
@@ -193,6 +193,14 @@
                                'value' => 
$this->specialPage->getUser()->getEditToken()
                        ]
                ) .
+               Html::element(
+                       'input',
+                       [
+                               'type' => 'hidden',
+                               'name' => 'action',
+                               'value' => 'submit',
+                       ]
+               ) .
                new ButtonInputWidget(
                        [
                                'classes' => [ 'mw-importfile-import-submit' ],
diff --git a/src/Html/InputFormPage.php b/src/Html/InputFormPage.php
index 2ab87a1..d361571 100644
--- a/src/Html/InputFormPage.php
+++ b/src/Html/InputFormPage.php
@@ -46,7 +46,7 @@
                        'form',
                        [
                                'action' => 
$this->specialPage->getPageTitle()->getLocalURL(),
-                               'method' => 'GET',
+                               'method' => 'POST',
                        ]
                ) .
                        new TextInputWidget(
diff --git a/src/SpecialImportFile.php b/src/SpecialImportFile.php
index c77da8e..777f30e 100644
--- a/src/SpecialImportFile.php
+++ b/src/SpecialImportFile.php
@@ -149,9 +149,7 @@
                }
 
                if ( $out->getRequest()->wasPosted() ) {
-                       $this->actuallyExecutePost( $importDetails );
-               } else {
-                       $this->actuallyExecuteGet( $sourceUrl, $importDetails );
+                       $this->actuallyExecute( $sourceUrl, $importDetails );
                }
        }
 
@@ -229,17 +227,15 @@
                return true;
        }
 
-       private function actuallyExecutePost( $importDetails ) {
-               $importResult = $this->doImport( $importDetails );
-               if ( !$importResult ) {
-                       $this->showImportPage( $importDetails );
-               }
-       }
-
-       private function actuallyExecuteGet( $sourceUrl, ImportDetails 
$importDetails ) {
+       private function actuallyExecute( $sourceUrl, ImportDetails 
$importDetails ) {
                $out = $this->getOutput();
                $action = $this->getRequest()->getVal( 'action' );
-               if ( $action === 'edittitle' ) {
+               if ( $action === 'submit' ) {
+                       $importResult = $this->doImport( $importDetails );
+                       if ( !$importResult ) {
+                               $this->showImportPage( $importDetails );
+                       }
+               } elseif ( $action === 'edittitle' ) {
                        $out->addHTML(
                                ( new ChangeTitleForm( $this, $sourceUrl, 
$importDetails->getTargetTitle() ) )
                                        ->getHtml()

-- 
To view, visit https://gerrit.wikimedia.org/r/362254
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbe6724e155a608b6122ad1b421251c0958aeb64
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FileImporter
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to