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

Change subject: WorkflowLoaderFactory: Don't crash for negative namespace titles
......................................................................

WorkflowLoaderFactory: Don't crash for negative namespace titles

* Throw a proper exception from Flow if this case occurs.
* However, prevent it from reaching that layer using a user-facing
API error.
* Cleanup unnecessary type check (we have a type hint).

Bug: T175085
Change-Id: I91d49f708c30f936ff01455e5e00ff50c9768001
(cherry picked from commit 161be17991893881713e62f95fbb4b84fe58ce66)
---
M includes/Api/ApiFlow.php
M includes/WorkflowLoaderFactory.php
2 files changed, 12 insertions(+), 1 deletion(-)


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

diff --git a/includes/Api/ApiFlow.php b/includes/Api/ApiFlow.php
index b60d16e..4863cc9 100644
--- a/includes/Api/ApiFlow.php
+++ b/includes/Api/ApiFlow.php
@@ -113,6 +113,13 @@
                                [ 'apierror-invalidtitle', wfEscapeWikiText( 
$params['page'] ) ], 'invalid-page'
                        );
                }
+
+               if ( $page->getNamespace() < 0 ) {
+                       $this->dieWithError(
+                               [ 'apierror-invalidtitle', wfEscapeWikiText( 
$params['page'] ) ], 'invalid-page-negative-namespace'
+                       );
+               }
+
                /** @var \Flow\TalkpageManager $controller */
                $controller = Container::get( 'occupation_controller' );
                if ( $page->getContentModel() !== CONTENT_MODEL_FLOW_BOARD ) {
diff --git a/includes/WorkflowLoaderFactory.php 
b/includes/WorkflowLoaderFactory.php
index 47ea19c..59f9f8f 100644
--- a/includes/WorkflowLoaderFactory.php
+++ b/includes/WorkflowLoaderFactory.php
@@ -62,10 +62,14 @@
         * @throws CrossWikiException
         */
        public function createWorkflowLoader( Title $pageTitle, $workflowId = 
null ) {
-               if ( $pageTitle && $pageTitle->isExternal() ) {
+               if ( $pageTitle->isExternal() ) {
                        throw new CrossWikiException( 'Interwiki to ' . 
$pageTitle->getInterwiki() . ' not implemented ', 'default' );
                }
 
+               if ( $pageTitle->getNamespace() < 0 ) {
+                       throw new InvalidDataException( 'Can not load workflow 
for special (< 0) namespace', 'invalid-title' );
+               }
+
                // @todo: ideally, workflowId is always set and this stuff is 
done in the places that call this
                if ( $workflowId === null ) {
                        if ( $pageTitle->getNamespace() === NS_TOPIC ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I91d49f708c30f936ff01455e5e00ff50c9768001
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: wmf/1.30.0-wmf.17
Gerrit-Owner: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>

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

Reply via email to