API: (bug 18099) Editing a non-existent page with appendtext caused the contents...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 24 Mar 2009 16:15:43 +0000 (16:15 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 24 Mar 2009 16:15:43 +0000 (16:15 +0000)
RELEASE-NOTES
includes/api/ApiEditPage.php

index af7abc3..7a6f6fc 100644 (file)
@@ -331,6 +331,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * BREAKING CHANGE: action=purge requires write rights and, for anonymous users,
   a POST request
 * (bug 15935) Added action=userrights to add/remove users to/from groups
+* (bug 18099) Using appendtext to edit a non-existent page causes an interface
+  message to be included in the page text
 
 === Languages updated in 1.15 ===
 
index a66006b..1e39276 100644 (file)
@@ -75,7 +75,14 @@ class ApiEditPage extends ApiBase {
                $toMD5 = $params['text'];
                if(!is_null($params['appendtext']) || !is_null($params['prependtext']))
                {
-                       $content = $articleObj->getContent();
+                       // For non-existent pages, Article::getContent()
+                       // returns an interface message rather than ''
+                       // We do want getContent()'s behavior for non-existent
+                       // MediaWiki: pages, though
+                       if($articleObj->getID() == 0 && $titleObj->getNamespace() != NS_MEDIAWIKI)
+                               $content = '';
+                       else
+                               $content = $articleObj->getContent();
                        $params['text'] = $params['prependtext'] . $content . $params['appendtext'];
                        $toMD5 = $params['prependtext'] . $params['appendtext'];
                }