jenkins-bot has submitted this change and it was merged.

Change subject: Add some logging for weird redirected POSTs
......................................................................


Add some logging for weird redirected POSTs

Change-Id: Ib19ebc2306e85fdb8c29b5850f2306bec7907938
---
M includes/Wiki.php
1 file changed, 14 insertions(+), 2 deletions(-)

Approvals:
  Parent5446: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Wiki.php b/includes/Wiki.php
index 6e72b9d..998ec41 100644
--- a/includes/Wiki.php
+++ b/includes/Wiki.php
@@ -513,8 +513,20 @@
                        ) &&
                        $request->detectProtocol() == 'http'
                ) {
-                       $redirUrl = $request->getFullRequestURL();
-                       $redirUrl = str_replace( 'http://', 'https://', 
$redirUrl );
+                       $oldUrl = $request->getFullRequestURL();
+                       $redirUrl = str_replace( 'http://', 'https://', $oldUrl 
);
+
+                       if ( $request->wasPosted() ) {
+                               // This is weird and we'd hope it almost never 
happens. This
+                               // means that a POST came in via HTTP and 
policy requires us
+                               // redirecting to HTTPS. It's likely such a 
request is going
+                               // to fail due to post data being lost, but 
let's try anyway
+                               // and just log the instance.
+                               //
+                               // @todo @fixme See if we could issue a 307 or 
308 here, need
+                               // to see how clients (automated & browser) 
behave when we do
+                               wfDebugLog( 'RedirectedPosts', "Redirected from 
HTTP to HTTPS: $oldUrl" );
+                       }
 
                        // Setup dummy Title, otherwise OutputPage::redirect 
will fail
                        $title = Title::newFromText( NS_MAIN, 'REDIR' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib19ebc2306e85fdb8c29b5850f2306bec7907938
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Demon <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to