Legoktm has uploaded a new change for review.

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


Change subject: If using &section=new, it is possible the page won't exist.
......................................................................

If using &section=new, it is possible the page won't exist.

If the page doesn't exist, $articleObject->replaceSectionContent will return 
null
Fixes a regression introduced in be97167ab61e7d59d86f6a9dca53b7016d615735.

Bug: 52830
Change-Id: Icdc0f130eeb40fff5c656c396b2a2af294015b98
---
M includes/api/ApiEditPage.php
1 file changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/31/79031/1

diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 9c079da..a8dc3b4 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -341,14 +341,15 @@
                        }
 
                        $contentObj = $contentHandler->unserializeContent( 
$content, $contentFormat );
-
-                       $fullContentObj = 
$articleObject->replaceSectionContent( $params['section'], $contentObj, 
$sectionTitle );
-                       if ( $fullContentObj ) {
-                               $content = $fullContentObj->serialize( 
$contentFormat );
-                       } else {
-                               // This most likely means we have an edit 
conflict which means that the edit
-                               // wont succeed anyway.
-                               $this->dieUsageMsg( 'editconflict' );
+                       if ( $titleObj->exists() ) { // If the page doesn't 
exist, there is no current content (bug 52830)
+                               $fullContentObj = 
$articleObject->replaceSectionContent( $params['section'], $contentObj, 
$sectionTitle );
+                               if ( $fullContentObj ) {
+                                       $content = $fullContentObj->serialize( 
$contentFormat );
+                               } else {
+                                       // This most likely means we have an 
edit conflict which means that the edit
+                                       // wont succeed anyway.
+                                       $this->dieUsageMsg( 'editconflict' );
+                               }
                        }
                }
 

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

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

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

Reply via email to