Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/51007


Change subject: (bug 44921) API should properly handle OPTIONS
......................................................................

(bug 44921) API should properly handle OPTIONS

When given an OPTIONS request, ApiMain should return just after the CORS
check. It should not actually execute the action or return any response
body.

Change-Id: I1c16cb89e777aaac69ae86b532d16f4c10a1f1d2
---
M RELEASE-NOTES-1.21
M includes/api/ApiMain.php
2 files changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/07/51007/1

diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index 51259de..bd72d8b 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -233,6 +233,8 @@
   particular page property.
 * Added an API query module list=pagepropnames, which lists all page prop names
   currently in use on the wiki.
+* (bug 44921) ApiMain::execute() will now return after the CORS check for an
+  HTTP OPTIONS request.
 
 === API internal changes in 1.21 ===
 * For debugging only, a new global $wgDebugAPI removes many API restrictions 
when true.
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index c3ae8b1..1dabbbf 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -364,6 +364,12 @@
                        return;
                }
 
+               // Exit here if the request method was OPTIONS
+               // (assume there will be a followup GET or POST)
+               if ( $this->getRequest()->getMethod() === 'OPTIONS' ) {
+                       return;
+               }
+
                // In case an error occurs during data output,
                // clear the output buffer and print just the error information
                ob_start();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c16cb89e777aaac69ae86b532d16f4c10a1f1d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

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

Reply via email to