jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/376447 )

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
---
M includes/Api/ApiFlow.php
M includes/WorkflowLoaderFactory.php
2 files changed, 12 insertions(+), 1 deletion(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



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/376447
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I91d49f708c30f936ff01455e5e00ff50c9768001
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Sbisson <sbis...@wikimedia.org>
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