Make powersearch form use POST if JS is disabled
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 8 May 2019 20:32:19 +0000 (13:32 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 8 May 2019 20:39:57 +0000 (13:39 -0700)
This means that the rememberme checkbox will not result in DB
writes on HTTP GET. If JS is enabled, it becomes GET initially.

Bug: T151903
Change-Id: If700ba9d6d1fe582d3d7c5660fcefd6d2639e4ee

includes/widget/search/SearchFormWidget.php

index 66b6566..7c28b5e 100644 (file)
@@ -50,12 +50,15 @@ class SearchFormWidget {
                $offset,
                $isPowerSearch
        ) {
+               $user = $this->specialSearch->getUser();
+
                return '<div class="mw-search-form-wrapper">' .
                        Xml::openElement(
                                'form',
                                [
                                        'id' => $isPowerSearch ? 'powersearch' : 'search',
-                                       'method' => 'get',
+                                       // T151903: default to POST in case JS is disabled
+                                       'method' => ( $isPowerSearch && $user->isLoggedIn() ) ? 'post' : 'get',
                                        'action' => wfScript(),
                                ]
                        ) .