Anomie has uploaded a new change for review.

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


Change subject: API: DWIM for action=edit&section=new&appendtext=...
......................................................................

API: DWIM for action=edit&section=new&appendtext=...

While it doesn't make a whole lot of sense to prepend or append with
section=new, the user certainly doesn't intend to be copying the
contents of section 0. In the spirit of "do what I mean", we should
probably prepend/append to empty text in this situation.

Bug: 52538
Change-Id: I9b03635906ca665a4f68b3bd35d05ae9108e2356
---
M RELEASE-NOTES-1.22
M includes/api/ApiEditPage.php
2 files changed, 12 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/16/77716/1

diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index a36d8cf..51ea254 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -293,6 +293,8 @@
   with the content.
 * (bug 51342) prop=imageinfo iicontinue now contains the dbkey, not the text
   version of the title.
+* (bug 52538) action=edit will now use empty text instead of the contents
+  of section 0 when passed prependtext or appendtext with section=new.
 
 === Languages updated in 1.22===
 
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 22e4ded..9c079da 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -159,12 +159,17 @@
                                        $this->dieUsage( "Sections are not 
supported for this content model: $modelName.", 'sectionsnotsupported' );
                                }
 
-                               // Process the content for section edits
-                               $section = intval( $params['section'] );
-                               $content = $content->getSection( $section );
+                               if ( $params['section'] == 'new' ) {
+                                       // DWIM if they're trying to 
prepend/append to a new section.
+                                       $content = null;
+                               } else {
+                                       // Process the content for section edits
+                                       $section = intval( $params['section'] );
+                                       $content = $content->getSection( 
$section );
 
-                               if ( !$content ) {
-                                       $this->dieUsage( "There is no section 
{$section}.", 'nosuchsection' );
+                                       if ( !$content ) {
+                                               $this->dieUsage( "There is no 
section {$section}.", 'nosuchsection' );
+                                       }
                                }
                        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b03635906ca665a4f68b3bd35d05ae9108e2356
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