jenkins-bot has submitted this change and it was merged.

Change subject: Fix a failure in API when the page does not exists
......................................................................


Fix a failure in API when the page does not exists

Change-Id: I270247a20d492e60116c1adf020d01bd965565be
---
M ProofreadPage.body.php
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Phe: Looks good to me, but someone else must approve
  Tpt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php
index 9089369..5bcecf9 100644
--- a/ProofreadPage.body.php
+++ b/ProofreadPage.body.php
@@ -691,16 +691,21 @@
                        return true;
                }
 
+               $contentHandler = ContentHandler::getForModelID( 
CONTENT_MODEL_PROOFREAD_PAGE );
                $article = $editPage->getArticle();
                $user = $article->getContext()->getUser();
                $oldContent = $article->getPage()->getContent( 
Revision::FOR_THIS_USER, $user );
-               $newContent = ContentHandler::makeContent( $text, 
$editPage->getTitle(), $editPage->contentModel, $editPage->contentFormat );
+               $newContent = $contentHandler->unserializeContent( $text, 
$editPage->getTitle(), $editPage->contentFormat );
 
                if ( !$newContent->isValid() ) {
                        $resultArr['badpage'] = wfMessage( 
'proofreadpage_badpagetext' )->text();
                        return false;
                }
 
+               if ( $oldContent === null ) {
+                       $oldContent = $contentHandler->makeEmptyContent();
+               }
+
                $oldLevel = $oldContent->getLevel();
                $newLevel = $newContent->getLevel();
                //if the user change the level, the change should be allowed 
and the new User should be the editing user

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I270247a20d492e60116c1adf020d01bd965565be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: Phe <phil...@free.fr>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to