(bug 16019) Make WebRequest::interpolateTitle() do nothing when run from api.php
authorIlmari Karonen <vyznev@users.mediawiki.org>
Fri, 10 Dec 2010 22:39:17 +0000 (22:39 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Fri, 10 Dec 2010 22:39:17 +0000 (22:39 +0000)
RELEASE-NOTES
api.php
includes/WebRequest.php

index 48f998b..de3c6d8 100644 (file)
@@ -33,6 +33,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Page existence is now not revealed (in the colour of the tabs) to users who
   cannot read the page in question.
 * (bug 19006) {{REVISIONUSER}} no longer acts like {{CURRENTUSER}} in some cases
+* (bug 16019) $wgArticlePath = "/$1" no longer breaks API edit/watch actions
 
 === API changes in 1.18 ===
 
diff --git a/api.php b/api.php
index 7246cf1..370884d 100644 (file)
--- a/api.php
+++ b/api.php
@@ -34,6 +34,9 @@
  * in the URL.
  */
 
+// So extensions (and other code) can check whether they're running in API mode
+define( 'MW_API', true );
+
 // Initialise common code
 require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
 
@@ -99,9 +102,6 @@ if ( $wgCrossSiteAJAXdomains && isset( $_SERVER['HTTP_ORIGIN'] ) ) {
        }
 }
 
-// So extensions can check whether they're running in API mode
-define( 'MW_API', true );
-
 // Set a dummy $wgTitle, because $wgTitle == null breaks various things
 // In a perfect world this wouldn't be necessary
 $wgTitle = Title::makeTitle( NS_MAIN, 'API' );
index 4cd120a..7ec8c67 100644 (file)
@@ -65,6 +65,11 @@ class WebRequest {
        public function interpolateTitle() {
                global $wgUsePathInfo;
 
+               // bug 16019: title interpolation on API queries is useless and possible harmful
+               if ( defined( 'MW_API' ) ) {
+                       return;
+               }
+
                if ( $wgUsePathInfo ) {
                        // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892
                        // And also by Apache 2.x, double slashes are converted to single slashes.