Catrope has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/353966 )

Change subject: TalkpageManager: Add non-master mode to 
checkIfCreationIsPossible() for API
......................................................................

TalkpageManager: Add non-master mode to checkIfCreationIsPossible() for API

The API calls this function for all requests, even on GET, so it needs
to not query the master in that case. But in all other cases, it's called
to prepare for creating a page, and it does need to query the master.

Bug: T165251
Change-Id: I212994e71ddc9765561e80f9a0e1346c2853eda8
---
M includes/Api/ApiFlow.php
M includes/TalkpageManager.php
2 files changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/66/353966/1

diff --git a/includes/Api/ApiFlow.php b/includes/Api/ApiFlow.php
index d55ccd9..6623be6 100644
--- a/includes/Api/ApiFlow.php
+++ b/includes/Api/ApiFlow.php
@@ -119,7 +119,8 @@
                        // Just check for permissions, nothing else to do. The 
Flow board
                        // will be put in place right before the rest of the 
data is stored
                        // (in SubmissionHandler::commit), after everything's 
been validated.
-                       $status = $controller->safeAllowCreation( $page, 
$this->getUser() );
+                       $status = $controller->safeAllowCreation( $page, 
$this->getUser(),
+                               /* $mustNotExist = */ true, /* $forWrite = */ 
false );
                        if ( !$status->isGood() ) {
                                $this->dieWithError( [ 
'apierror-flow-safeallowcreationfailed', $status->getMessage() ], 
'invalid-page' );
                        }
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index b1882ec..8befa0b 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -143,7 +143,7 @@
        /**
         * {@inheritdoc}
         */
-       public function checkIfCreationIsPossible( Title $title, $mustNotExist 
= true) {
+       public function checkIfCreationIsPossible( Title $title, $mustNotExist 
= true, $forWrite = true ) {
                global $wgContentHandlerUseDB;
 
                // Arbitrary pages can only be enabled when content handler
@@ -154,7 +154,7 @@
 
                // Only allow converting a non-existent page to Flow
                if ( $mustNotExist ) {
-                       if ( $title->exists( Title::GAID_FOR_UPDATE ) ) {
+                       if ( $title->exists( $forWrite ? Title::GAID_FOR_UPDATE 
: 0 ) ) {
                                return Status::newFatal( 
'flow-error-allowcreation-already-exists' );
                        }
                }
@@ -185,10 +185,10 @@
        /**
         * {@inheritdoc}
         */
-       public function safeAllowCreation( Title $title, User $user, 
$mustNotExist = true ) {
+       public function safeAllowCreation( Title $title, User $user, 
$mustNotExist = true, $forWrite = true ) {
                $status = Status::newGood();
 
-               $technicallyAllowedStatus = $this->checkIfCreationIsPossible( 
$title, $mustNotExist );
+               $technicallyAllowedStatus = $this->checkIfCreationIsPossible( 
$title, $mustNotExist, $forWrite );
 
                $permissionStatus = $this->checkIfUserHasPermission( $title, 
$user );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I212994e71ddc9765561e80f9a0e1346c2853eda8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

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

Reply via email to