EBernhardson (WMF) has uploaded a new change for review.

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


Change subject: Attach workflows to non-existant titles
......................................................................

Attach workflows to non-existant titles

Change-Id: I0edeb7f86db03623a8c0d3f122173128b905624c
---
M container.php
M flow.sql
M includes/Model/Workflow.php
M includes/WorkflowLoader.php
4 files changed, 6 insertions(+), 9 deletions(-)


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

diff --git a/container.php b/container.php
index 02981e3..3a33d48 100644
--- a/container.php
+++ b/container.php
@@ -103,7 +103,7 @@
                // This is actually a unique index, but it wants the shallow 
functionality.
                new TopKIndex(
                        $cache, $storage, 'flow_workflow:title',
-                       array( 'workflow_wiki', 'workflow_page_id', 
'workflow_definition_id' ),
+                       array( 'workflow_wiki', 'workflow_namespace', 
'workflow_title_text', 'workflow_definition_id' ),
                        array( 'shallow' => $pk, 'limit' => 1, 'sort' => 
'workflow_id' )
                ),
        );
diff --git a/flow.sql b/flow.sql
index 2cac549..1ac0d6c 100644
--- a/flow.sql
+++ b/flow.sql
@@ -31,6 +31,8 @@
        PRIMARY KEY (workflow_id)
 ) /*$wgDBTableOptions*/;
 
+CREATE INDEX /*i*/flow_workflow_lookup ON /*_*/flow_workflow (workflow_wiki, 
workflow_namespace, workflow_title_text, workflow_definition_id);
+
 CREATE TABLE /*_*/flow_subscription (
   subscription_workflow_id int unsigned not null,
   subscription_user_id int unsigned not null,
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index bc7194f..e1d79c1 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -129,9 +129,6 @@
        // these are exceptions currently to make debugging easier
        // it should return false later on to allow wider use.
        public function matchesTitle( Title $title ) {
-               if ( $title->getArticleID() === 0 ) {
-                       return false; // non-existant page
-               }
                if ( $title->getNamespace() !== $this->namespace ) {
                        throw new \Exception( 'namespace' );
                }
diff --git a/includes/WorkflowLoader.php b/includes/WorkflowLoader.php
index 89b8dca..0387146 100644
--- a/includes/WorkflowLoader.php
+++ b/includes/WorkflowLoader.php
@@ -27,11 +27,8 @@
                if ( $pageTitle === null ) {
                        throw new \MWException( 'Invalid article requested' );
                }
-               if ( $pageTitle && $pageTitle->mInterwiki ) {
+               if ( $pageTitle->mInterwiki ) {
                        throw new \MWException( 'Interwiki not implemented yet' 
);
-               }
-               if ( $pageTitle && $pageTitle->getArticleID() === 0 ) {
-                       throw new \MWException( 'Can only load workflows for 
existing page. Page '.( $pageTitle->getPrefixedText() ). ' does not exist.' );
                }
 
                $this->storage = $storage;
@@ -75,7 +72,8 @@
                $found = $storage->find( array(
                        'workflow_definition_id' => $definition->getId(),
                        'workflow_wiki' => $title->isLocal() ? wfWikiId() : 
$title->getTransWikiID(),
-                       'workflow_page_id' => $title->getArticleID(),
+                       'workflow_namespace' => $title->getNamespace(),
+                       'workflow_title_text' => $title->getDBkey(),
                ) );
                if ( $found ) {
                        $workflow = reset( $found );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0edeb7f86db03623a8c0d3f122173128b905624c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) <ebernhard...@wikimedia.org>

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

Reply via email to