EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/115576
Change subject: [SCHEMA CHANGE] Drop the definition model ...................................................................... [SCHEMA CHANGE] Drop the definition model The definition hangs around but doesn't do anything for us currently. Its an idea for the future of user defined workflows, but we dont really know how those might work yet. It requires a network request or two on every page and gives us little in reutrn. Based on this lets just remove it for now and if needed later can be revived. Change-Id: I470e7f1705166420d465df72f907c18e61ee0f89 --- M Flow.php M Hooks.php M container.php M flow.sql M includes/Block/TopicList.php M includes/Data/RecentChanges.php M includes/Exception/ExceptionHandling.php D includes/Model/Definition.php M includes/Model/PostRevision.php M includes/Model/Workflow.php M includes/UrlGenerator.php M includes/WorkflowLoader.php D maintenance/FlowInsertDefaultDefinitions.php 13 files changed, 58 insertions(+), 358 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/76/115576/1 diff --git a/Flow.php b/Flow.php index d9a35ac..4e44a16 100755 --- a/Flow.php +++ b/Flow.php @@ -49,8 +49,6 @@ $wgExtensionMessagesFiles['Flow'] = $dir . 'Flow.i18n.php'; -$wgAutoloadClasses['FlowInsertDefaultDefinitions'] = $dir . 'maintenance/FlowInsertDefaultDefinitions.php'; - // Classes fulfilling the mediawiki extension architecture // note: SRP would say a 'FlowHooks' class should not exist $wgAutoloadClasses['FlowHooks'] = $dir . 'Hooks.php'; @@ -80,7 +78,6 @@ $wgAutoloadClasses['Flow\TermsOfUse'] = $dir . 'includes/TermsOfUse.php'; // Classes that model our data -$wgAutoloadClasses['Flow\Model\Definition'] = $dir . 'includes/Model/Definition.php'; $wgAutoloadClasses['Flow\Model\Metadata'] = $dir . 'includes/Model/Metadata.php'; $wgAutoloadClasses['Flow\Model\AbstractRevision'] = $dir . 'includes/Model/AbstractRevision.php'; $wgAutoloadClasses['Flow\Model\PostRevision'] = $dir . 'includes/Model/PostRevision.php'; diff --git a/Hooks.php b/Hooks.php index 27fef73..557ec39 100644 --- a/Hooks.php +++ b/Hooks.php @@ -47,7 +47,7 @@ $updater->modifyExtensionField( 'flow_summary_revision', 'summary_workflow_id', "$dir/db_patches/patch-summary2header.sqlite.sql" ); $updater->modifyExtensionField( 'flow_revision', 'rev_comment', "$dir/db_patches/patch-rev_change_type.sqlite.sql" ); // sqlite ignores field types, this just substr's uuid's to 88 bits - $updater->modifyExtensionField( 'flow_definition', 'definition_id', "$dir/db_patches/patch-88bit_uuids.sqlite.sql" ); + $updater->modifyExtensionField( 'flow_workflow', 'workflow_id', "$dir/db_patches/patch-88bit_uuids.sqlite.sql" ); } else { // sqlite doesn't support alter table change, it also considers all types the same so // this patch doesn't matter to it. @@ -57,7 +57,7 @@ // rename rev_change_type -> rev_comment, alternate patch is above for sqlite $updater->modifyExtensionField( 'flow_revision', 'rev_comment', "$dir/db_patches/patch-rev_change_type.sql" ); // convert 128 bit uuid's into 88bit - $updater->modifyExtensionField( 'flow_definition', 'definition_id', "$dir/db_patches/patch-88bit_uuids.sql" ); + $updater->modifyExtensionField( 'flow_workflow', 'workflow_id', "$dir/db_patches/patch-88bit_uuids.sql" ); } $updater->addExtensionIndex( 'flow_workflow', 'flow_workflow_lookup', "$dir/db_patches/patch-workflow_lookup_idx.sql" ); @@ -66,6 +66,8 @@ $updater->modifyExtensionField( 'recentchanges', 'rc_source', "$dir/db_patches/patch-rc_source.sql" ); $updater->modifyExtensionField( 'flow_revision', 'rev_change_type', "$dir/db_patches/patch-censor_to_suppress.sql" ); $updater->addExtensionField( 'flow_workflow', 'workflow_user_ip', "$dir/db_patches/patch-remove_usernames.sql" ); + $updater->addExtensionField( 'flow_workflow', 'workflow_type', "$dir/db_patches/patch-add_workflow_type.sql" ); + $updater->dropExtensionTable( 'flow_definition', false ); require_once __DIR__.'/maintenance/FlowInsertDefaultDefinitions.php'; $updater->addPostDatabaseUpdateMaintenance( 'FlowInsertDefaultDefinitions' ); diff --git a/container.php b/container.php index f9632cb..99bc4f0 100644 --- a/container.php +++ b/container.php @@ -131,23 +131,6 @@ $c['repository.username'] = $c->share( function( $c ) { return new Flow\Data\UserNameBatch( new Flow\Data\TwoStepUsernameQuery( $c['db.factory'] ) ); } ); -// Per wiki workflow definitions (types of workflows) -$c['storage.definition'] = $c->share( function( $c ) { - $cache = $c['memcache.buffered']; - $mapper = BasicObjectMapper::model( 'Flow\\Model\\Definition' ); - $storage = new BasicDbStorage( - // factory and table - $c['db.factory'], 'flow_definition', - // pk - array( 'definition_id' ) - ); - $indexes = array( - new UniqueFeatureIndex( $cache, $storage, 'flow_definition:pk', array( 'definition_id' ) ), - new UniqueFeatureIndex( $cache, $storage, 'flow_definition:name', array( 'definition_wiki', 'definition_name' ) ), - ); - - return new ObjectManager( $mapper, $storage, $indexes ); -} ); // Individual workflow instances $c['storage.workflow'] = $c->share( function( $c ) { $cache = $c['memcache.buffered']; @@ -164,7 +147,7 @@ // This is actually a unique index, but it wants the shallow functionality. new TopKIndex( $cache, $storage, 'flow_workflow:title', - array( 'workflow_wiki', 'workflow_namespace', 'workflow_title_text', 'workflow_definition_id' ), + array( 'workflow_wiki', 'workflow_namespace', 'workflow_title_text'), array( 'shallow' => $pk, 'limit' => 1, 'sort' => 'workflow_id' ) ), ); @@ -386,9 +369,6 @@ return new \Flow\Data\ManagerGroup( $c, array( - 'Flow\\Model\\Definition' => 'storage.definition', - 'Definition' => 'storage.definition', - 'Flow\\Model\\Workflow' => 'storage.workflow', 'Workflow' => 'storage.workflow', diff --git a/flow.sql b/flow.sql index 1832689..ea78a4a 100644 --- a/flow.sql +++ b/flow.sql @@ -1,16 +1,6 @@ -- Database schema for Flow -- This file contains only the unsharded global data -CREATE TABLE /*_*/flow_definition ( - definition_id binary(11) NOT NULL, - definition_wiki varchar(32) binary NOT NULL, - definition_name varchar(32) binary NOT NULL, - definition_type varchar(32) binary NOT NULL, - definition_options BLOB NULL, -- should instead be revisioned blob - PRIMARY KEY (definition_id) -) /*$wgDBTableOptions*/; -CREATE UNIQUE INDEX /*i*/flow_definition_unique_name ON /*_*/flow_definition (definition_wiki, definition_name); - CREATE TABLE /*_*/flow_workflow ( workflow_id binary(11) not null, workflow_wiki varchar(16) binary not null, @@ -25,11 +15,10 @@ -- TODO: is this usefull as a bitfield? may be premature optimization, a string -- or list of strings may be simpler and use only a little more space. workflow_lock_state int unsigned not null, - workflow_definition_id binary(11) not null, 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 INDEX /*i*/flow_workflow_lookup ON /*_*/flow_workflow (workflow_wiki, workflow_namespace, workflow_title_text); CREATE TABLE /*_*/flow_subscription ( subscription_workflow_id int unsigned not null, diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php index 60b3cf5..0d4302d 100644 --- a/includes/Block/TopicList.php +++ b/includes/Block/TopicList.php @@ -79,20 +79,8 @@ * @return array Array of [$topicWorkflow, $topicListEntry, $topicPost, $firstPost] */ protected function create() { - $defStorage = $this->storage->getStorage( 'Definition' ); - $sourceDef = $defStorage->get( $this->workflow->getDefinitionId() ); - - if ( !$sourceDef ) { - throw new \MWException( "Unable to retrieve definition for this workflow" ); - } - - $topicDef = $defStorage->get( $sourceDef->getOption( 'topic_definition_id' ) ); - if ( !$topicDef ) { - throw new FailCommitException( 'Invalid definition owns this TopicList, needs a valid topic_definition_id option assigned', 'fail-commit' ); - } - $title = $this->workflow->getArticleTitle(); - $topicWorkflow = Workflow::create( $topicDef, $this->user, $title ); + $topicWorkflow = Workflow::create( 'topic', $this->user, $title ); $topicListEntry = TopicListEntry::create( $this->workflow, $topicWorkflow ); if ( !$title->exists() ) { diff --git a/includes/Data/RecentChanges.php b/includes/Data/RecentChanges.php index df2da0b..cc844c1 100644 --- a/includes/Data/RecentChanges.php +++ b/includes/Data/RecentChanges.php @@ -105,7 +105,6 @@ 'revision_type' => $revisionType, 'revision' => $revisionId, 'workflow' => $workflow->getId()->getAlphadecimal(), - 'definition' => $workflow->getDefinitionId()->getAlphadecimal(), ) + $changes, ) ), 'rc_cur_id' => 0, diff --git a/includes/Exception/ExceptionHandling.php b/includes/Exception/ExceptionHandling.php index 795feed..b77189c 100644 --- a/includes/Exception/ExceptionHandling.php +++ b/includes/Exception/ExceptionHandling.php @@ -125,7 +125,6 @@ 'invalid-input', 'missing-revision', 'revision-comparison', - 'invalid-definition', 'invalid-workflow' ); } diff --git a/includes/Model/Definition.php b/includes/Model/Definition.php deleted file mode 100644 index 0bb778a..0000000 --- a/includes/Model/Definition.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php - -namespace Flow\Model; - -use Flow\Exception\DataModelException; -use Flow\Exception\InvalidDataException; - -class Definition { - /** - * @var UUID - */ - protected $id; - - /** - * @var string - */ - protected $type; - - /** - * @var string - */ - protected $wiki; - - /** - * @var string - */ - protected $name; - - /** - * @var array - */ - protected $options = array(); - - /** - * @param array $row - * @param object|null $obj - * @return Definition - * @throws InvalidDataException - * @throws DataModelException - */ - static public function fromStorageRow( array $row, $obj = null ) { - if ( !$row['definition_wiki'] ) { - throw new InvalidDataException( "No definition_wiki", 'fail-load-data' ); - } - if ( $obj === null ) { - $obj = new self; - } elseif ( !$obj instanceof self ) { - throw new DataModelException( 'Wrong obj type: ' . get_class( $obj ), 'process-data' ); - } - $obj->id = UUID::create( $row['definition_id'] ); - $obj->type = $row['definition_type']; - $obj->wiki = $row['definition_wiki']; - $obj->name = $row['definition_name']; - $obj->options = $row['definition_options'] ? unserialize( $row['definition_options'] ) : array(); - return $obj; - } - - /** - * @param Definition $obj - * @return array - */ - static public function toStorageRow( Definition $obj ) { - return array( - 'definition_id' => $obj->id->getBinary(), - 'definition_type' => $obj->type, - 'definition_wiki' => $obj->wiki, - 'definition_name' => $obj->name, - 'definition_options' => $obj->options ? serialize( $obj->options ) : null, - ); - } - - /** - * @param string $name - * @param string $type - * @param array $options - * @return Definition - */ - static public function create( $name, $type, array $options = array() ) { - $obj = new self; - $obj->id = UUID::create(); - $obj->wiki = wfWikiId(); - $obj->name = $name; - $obj->type = $type; - $obj->options = $options; - return $obj; - } - - /** - * @return UUID - */ - public function getId() { - return $this->id; - } - - /** - * @return string - */ - public function getWiki() { - return $this->wiki; - } - - /** - * @return string - */ - public function getName() { - return $this->name; - } - - /** - * @return string - */ - public function getType() { - return $this->type; - } - - /** - * @return array - */ - public function getOptions() { - return $this->options; - } - - /** - * @return mixed - */ - public function getOption( $key, $default = null ) { - return array_key_exists( $key, $this->options ) ? $this->options[$key] : $default; - } - - /** - * @param \User $user - * @param \Title $title - * @return Workflow - */ - public function createWorkflow( \User $user, \Title $title ) { - return Workflow::create( $this, $user, $title ); - } -} - diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php index 5fd84e3..df9e366 100644 --- a/includes/Model/PostRevision.php +++ b/includes/Model/PostRevision.php @@ -116,7 +116,7 @@ * that this will do what you'd expect. * Unlike Title & User etc, a post is not something some object that can be * used in isolation: a post should always be retrieved via it's parents, - * via a workflow, via a definition, ... + * via a workflow, ... * The only reason we have this method is so that, when failing to load a * post, we can create a stub object. * diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php index 3be4cba..d04adb8 100644 --- a/includes/Model/Workflow.php +++ b/includes/Model/Workflow.php @@ -12,6 +12,11 @@ class Workflow { /** + * @var string[] + */ + static private $allowedTypes = array( 'discussion', 'topic' ); + + /** * @var UUID */ protected $id; @@ -20,6 +25,11 @@ * @var boolean false before writing to storage */ protected $isNew; + + /** + * @var string e.g. topic, discussion, etc. + */ + protected $type; /** * @var string @@ -61,11 +71,6 @@ protected $lockState; /** - * @var UUID - */ - protected $definitionId; - - /** * @var string */ protected $lastModified; @@ -86,6 +91,7 @@ } $obj->id = UUID::create( $row['workflow_id'] ); $obj->isNew = false; + $obj->type = $row['workflow_type']; $obj->wiki = $row['workflow_wiki']; $obj->pageId = $row['workflow_page_id']; $obj->namespace = (int) $row['workflow_namespace']; @@ -98,7 +104,6 @@ $obj->userIp = $row['workflow_user_text']; } $obj->lockState = $row['workflow_lock_state']; - $obj->definitionId = UUID::create( $row['workflow_definition_id'] ); $obj->lastModified = $row['workflow_last_update_timestamp']; return $obj; } @@ -110,6 +115,7 @@ static public function toStorageRow( Workflow $obj ) { return array( 'workflow_id' => $obj->id->getBinary(), + 'workflow_type' => $obj->type, 'workflow_wiki' => $obj->wiki, 'workflow_page_id' => $obj->pageId, 'workflow_namespace' => $obj->namespace, @@ -117,26 +123,25 @@ 'workflow_user_id' => $obj->userId, 'workflow_user_ip' => $obj->userIp, 'workflow_lock_state' => $obj->lockState, - 'workflow_definition_id' => $obj->definitionId->getBinary(), 'workflow_last_update_timestamp' => $obj->lastModified, ); } /** - * @param Definition $definition * @param User $user * @param Title $title * @return Workflow * @throws DataModelException */ - static public function create( Definition $definition, User $user, Title $title ) { + static public function create( $type, User $user, Title $title ) { + // temporary limitation untill we implement something more concrete + if ( !in_array( $type, self::$allowedTypes ) ) { + throw new DataModelException( 'Invalid workflow type provided: ' . $type, 'process-data' ); + } if ( $title->isLocal() ) { $wiki = wfWikiId(); } else { $wiki = $title->getTransWikiID(); - } - if ( $definition->getWiki() !== $wiki ) { - throw new DataModelException( 'Title and Definition are from separate wikis', 'process-data' ); } $obj = new self; @@ -144,13 +149,13 @@ // simpler in prototype to give everything an id up front? $obj->id = UUID::create(); $obj->isNew = true; // has not been persisted - $obj->wiki = $definition->getWiki(); + $obj->type = $type; + $obj->wiki = $wiki; $obj->pageId = $title->getArticleID(); $obj->namespace = $title->getNamespace(); $obj->titleText = $title->getDBkey(); list( $obj->userId, $obj->userIp ) = AbstractRevision::userFields( $user ); $obj->lockState = 0; - $obj->definitionId = $definition->getId(); $obj->updateLastModified(); return $obj; @@ -173,17 +178,17 @@ public function getId() { return $this->id; } /** + * @return string + */ + public function getType() { return $this->type; } + + /** * Returns true if the workflow is new as of this request (regardless of * whether or not is it already saved yet - that's unknown). * * @return boolean */ public function isNew() { return (bool) $this->isNew; } - - /** - * @return UUID - */ - public function getDefinitionId() { return $this->definitionId; } /** * @return integer diff --git a/includes/UrlGenerator.php b/includes/UrlGenerator.php index 71f6233..f588c92 100644 --- a/includes/UrlGenerator.php +++ b/includes/UrlGenerator.php @@ -144,12 +144,7 @@ throw new InvalidDataException( '$workflow is not UUID or Workflow instance' ); } - if ( $workflow->isNew() ) { - $query['definition'] = $workflow->getDefinitionId()->getAlphadecimal(); - } else { - // TODO: workflow parameter is only necessary if the definition is non-unique. Likely need to pass - // ManagerGroup into this class rather than the workflow ObjectManager so we can fetch definition as - // needed. + if ( !$workflow->isNew() ) { $query['workflow'] = $workflow->getId()->getAlphadecimal(); } diff --git a/includes/WorkflowLoader.php b/includes/WorkflowLoader.php index b00293e..301d557 100644 --- a/includes/WorkflowLoader.php +++ b/includes/WorkflowLoader.php @@ -17,12 +17,11 @@ class WorkflowLoader { protected $dbFactory, $bufferedCache; - protected $workflow, $definition, $storage, $rootPostLoader, $notificationController, $definitionRequest; + protected $workflow, $storage, $rootPostLoader, $notificationController; public function __construct( $pageTitle, /*UUID or NULL*/ $workflowId, - $definitionRequest, DbFactory $dbFactory, BufferedCache $bufferedCache, ManagerGroup $storage, @@ -43,42 +42,33 @@ $this->rootPostLoader = $rootPostLoader; $this->notificationController = $notificationController; - $this->definitionRequest = $definitionRequest; - - $workflow = null; - if ( $workflowId !== null ) { - list( $workflow, $definition ) = $this->loadWorkflowById( $pageTitle, $workflowId ); + $workflow = $this->loadWorkflowById( $pageTitle, $workflowId ); } else { - list( $workflow, $definition ) = $this->loadWorkflow( $pageTitle ); + $workflow = $this->loadWorkflow( $pageTitle ); } - if ( ! $workflow || ! $definition ) { - throw new InvalidDataException( 'Unable to load workflow and definition', 'fail-load-data' ); + if ( ! $workflow ) { + throw new InvalidDataException( 'Unable to load workflow', 'fail-load-data' ); } $this->workflow = $workflow; - $this->definition = $definition; - } - - public function getDefinition() { - return $this->definition; } public function getWorkflow() { return $this->workflow; } + /** + * @param \Title $title + * @return Workflow + */ protected function loadWorkflow( \Title $title ) { - global $wgUser; + global $wgUser, $wgFlowDefaultWorkflow; $storage = $this->storage->getStorage( 'Workflow'); - $definition = $this->loadDefinition(); - if ( !$definition->getOption( 'unique' ) ) { - throw new InvalidDataException( 'Workflow is non-unique, can only fetch object by title + id', 'fail-load-data' ); - } $found = $storage->find( array( - 'workflow_definition_id' => $definition->getId(), + 'workflow_type' => $wgFlowDefaultWorkflow, 'workflow_wiki' => $title->isLocal() ? wfWikiId() : $title->getTransWikiID(), 'workflow_namespace' => $title->getNamespace(), 'workflow_title_text' => $title->getDBkey(), @@ -86,12 +76,18 @@ if ( $found ) { $workflow = reset( $found ); } else { - $workflow = Workflow::create( $definition, $wgUser, $title ); + $workflow = Workflow::create( $wgFlowDefaultWorkflow, $wgUser, $title ); } - return array( $workflow, $definition ); + return $workflow; } + /** + * @param Title|false $title + * @param UUID $workflowId + * @return Workflow + * @throws InvalidInputException + */ protected function loadWorkflowById( /* Title or false */ $title, $workflowId ) { $workflow = $this->storage->getStorage( 'Workflow' )->get( $workflowId ); if ( !$workflow ) { @@ -100,41 +96,12 @@ if ( $title !== false && !$workflow->matchesTitle( $title ) ) { throw new InvalidInputException( 'Flow workflow is for different page', 'invalid-input' ); } - $definition = $this->storage->getStorage( 'Definition' )->get( $workflow->getDefinitionId() ); - if ( !$definition ) { - throw new InvalidInputException( 'Flow workflow references unknown definition id: ' . $workflow->getDefinitionId()->getAlphadecimal(), 'invalid-input' ); - } - return array( $workflow, $definition ); - } - - protected function loadDefinition() { - global $wgFlowDefaultWorkflow; - - $repo = $this->storage->getStorage( 'Definition' ); - $id = $this->definitionRequest; - if ( $id instanceof UUID ) { - $definition = $repo->get( $id ); - if ( $definition === null ) { - throw new InvalidInputException( "Unknown flow id '$id' requested", 'invalid-input' ); - } - } else { - $workflowName = $id ? $id : $wgFlowDefaultWorkflow; - $found = $repo->find( array( - 'definition_name' => strtolower( $workflowName ), - 'definition_wiki' => wfWikiId(), - ) ); - if ( $found ) { - $definition = reset( $found ); - } else { - throw new InvalidInputException( "Unknown flow type '$workflowName' requested", 'invalid-input' ); - } - } - return $definition; + return $workflow; } public function createBlocks( ) { - switch( $this->definition->getType() ) { + switch( $this->workflow->getType() ) { case 'discussion': $blocks = array( new HeaderBlock( $this->workflow, $this->storage, $this->notificationController ), @@ -149,16 +116,15 @@ break; default: - throw new InvalidInputException( 'Not Implemented', 'invalid-definition' ); + throw new InvalidInputException( 'Not Implemented: ' . $this->workflow->getType(), 'invalid-definition' ); } $return = array(); foreach ( $blocks as $block ) { - if ( !isset( $return[$block->getName()] ) ) { - $return[$block->getName()] = $block; - } else { + if ( isset( $return[$block->getName()] ) ) { throw new InvalidDataException( 'Multiple blocks with same name is not yet supported', 'fail-load-data' ); } + $return[$block->getName()] = $block; } return $return; @@ -272,11 +238,10 @@ $this->notificationController = $notificationController; } - public function createWorkflowLoader( $pageTitle, $workflowId = null, $definitionRequest = false ) { + public function createWorkflowLoader( $pageTitle, $workflowId = null ) { return new WorkflowLoader( $pageTitle, $workflowId, - $definitionRequest, $this->dbFactory, $this->bufferedCache, $this->storage, diff --git a/maintenance/FlowInsertDefaultDefinitions.php b/maintenance/FlowInsertDefaultDefinitions.php deleted file mode 100644 index 06ac518..0000000 --- a/maintenance/FlowInsertDefaultDefinitions.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -use Flow\Container; -use Flow\Model\UUID; - -require_once ( getenv( 'MW_INSTALL_PATH' ) !== false - ? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php' - : dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' ); - -/** - * Inserts Flow's default definitions - * - * @ingroup Maintenance - */ -class FlowInsertDefaultDefinitions extends LoggedUpdateMaintenance { - - protected function doDBUpdates() { - $container = Container::getContainer(); - $dbw = $container['db.factory']->getDB( DB_MASTER ); - - $res = $dbw->select( - /* table */'flow_definition', - /* select */'definition_id', - /* conds */array( 'definition_name' => 'topic', 'definition_wiki' => wfWikiId() ), - __METHOD__ - ); - if ( $res ) { - $res = $res->fetchRow(); - } - if ( !isset( $res['definition_id'] ) ) { - $this->insertDefinitions( $dbw ); - } - - return true; - } - - protected function insertDefinitions( DatabaseBase $dbw ) { - $topicId = UUID::create(); - $discussionId = UUID::create(); - - $dbw->insert( - 'flow_definition', - array( - 'definition_id' => $topicId->getBinary(), - 'definition_wiki' => wfWikiId(), - 'definition_name' => 'topic', - 'definition_type' => 'topic', - 'definition_options' => null - ), - __METHOD__ - ); - - $dbw->insert( - 'flow_definition', - array( - 'definition_id' => $discussionId->getBinary(), - 'definition_wiki' => wfWikiId(), - 'definition_name' => 'discussion', - 'definition_type' => 'discussion', - 'definition_options' => serialize( array( - 'topic_definition_id' => $topicId, - 'unique' => true, - ) ), - ), - __METHOD__ - ); - } - - /** - * Get the update key name to go in the update log table - * - * @return string - */ - protected function getUpdateKey() { - return 'FlowInsertDefaultDefinitions'; - } -} - -$maintClass = 'FlowInsertDefaultDefinitions'; // Tells it to run the class -require_once( RUN_MAINTENANCE_IF_MAIN ); -- To view, visit https://gerrit.wikimedia.org/r/115576 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I470e7f1705166420d465df72f907c18e61ee0f89 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits