jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Drop workflow_user_*
......................................................................
Hygiene: Drop workflow_user_*
We don't use this for anything, lets just get rid of it.
Change-Id: I7c759b46995c045405426239e95f40147e8aaecb
---
M Hooks.php
M container.php
M db_patches/patch-add-wiki.sql
A db_patches/patch-drop_workflow_user.sql
M db_patches/patch-remove_usernames.sql
M flow.sql
M includes/Block/TopicList.php
M includes/Data/Index/BoardHistoryIndex.php
M includes/Data/Index/TopicHistoryIndex.php
M includes/Model/PostRevision.php
M includes/Model/Workflow.php
M includes/WorkflowLoaderFactory.php
M maintenance/FlowUpdateUserWiki.php
M tests/phpunit/Data/Listener/RecentChangesListenerTest.php
M tests/phpunit/HookTest.php
M tests/phpunit/PostRevisionTestCase.php
M tests/phpunit/TemplatingTest.php
17 files changed, 36 insertions(+), 100 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Hooks.php b/Hooks.php
index 9d02eb8..144bf2d 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -139,8 +139,8 @@
$updater->modifyExtensionField( 'flow_revision',
'rev_change_type', "$dir/db_patches/patch-rev_change_type_update.sql" );
$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_user_wiki', "$dir/db_patches/patch-add-wiki.sql" );
+ $updater->addExtensionField( 'flow_revision', 'rev_user_ip',
"$dir/db_patches/patch-remove_usernames.sql" );
+ $updater->addExtensionField( 'flow_revision', 'rev_user_wiki',
"$dir/db_patches/patch-add-wiki.sql" );
$updater->addExtensionIndex( 'flow_tree_revision',
'flow_tree_descendant_rev_id', "$dir/db_patches/patch-flow_tree_idx_fix.sql" );
$updater->dropExtensionField( 'flow_tree_revision',
'tree_orig_create_time', "$dir/db_patches/patch-tree_orig_create_time.sql" );
$updater->addExtensionIndex( 'flow_revision',
'flow_revision_user', "$dir/db_patches/patch-revision_user_idx.sql" );
@@ -148,6 +148,7 @@
$updater->addExtensionField( 'flow_revision', 'rev_type_id',
"$dir/db_patches/patch-rev_type_id.sql" );
$updater->addExtensionTable( 'flow_ext_ref',
"$dir/db_patches/patch-add-linkstables.sql" );
$updater->dropExtensionTable( 'flow_definition',
"$dir/db_patches/patch-drop_definition.sql" );
+ $updater->dropExtensionField( 'flow_workflow',
'workflow_user_ip', "$dir/db_patches/patch-drop_workflow_user.sql" );
require_once __DIR__.'/maintenance/FlowUpdateRecentChanges.php';
$updater->addPostDatabaseUpdateMaintenance(
'FlowUpdateRecentChanges' );
@@ -163,7 +164,7 @@
* having executed this.
*/
if ( $updater->updateRowExists( 'FlowSetUserIp' ) ) {
- $updater->dropExtensionField( 'flow_workflow',
'workflow_user_text', "$dir/db_patches/patch-remove_usernames_2.sql" );
+ $updater->dropExtensionField( 'flow_revision',
'rev_user_text', "$dir/db_patches/patch-remove_usernames_2.sql" );
}
require_once __DIR__.'/maintenance/FlowUpdateUserWiki.php';
diff --git a/container.php b/container.php
index a664839..f96d0da 100644
--- a/container.php
+++ b/container.php
@@ -187,12 +187,6 @@
$c['storage.workflow.indexes.title_lookup']
);
};
-$c['storage.workflow.listeners.username'] = $c->share( function( $c ) {
- return new Flow\Data\Listener\UserNameListener(
- $c['repository.username'],
- array( 'workflow_user_id' => 'workflow_user_wiki' )
- );
-} );
$c['storage.workflow.listeners.topiclist'] = $c->share( function( $c ) {
return new Flow\Data\Listener\WorkflowTopicListListener(
$c['storage.topic_list'],
diff --git a/db_patches/patch-add-wiki.sql b/db_patches/patch-add-wiki.sql
index f4f0dc4..969fd32 100644
--- a/db_patches/patch-add-wiki.sql
+++ b/db_patches/patch-add-wiki.sql
@@ -1,6 +1,4 @@
-ALTER TABLE /*_*/flow_workflow ADD workflow_user_wiki varchar(32) binary not
null;
-
ALTER TABLE /*_*/flow_subscription ADD subscription_user_wiki varchar(32)
binary not null;
ALTER TABLE /*_*/flow_tree_revision ADD tree_orig_user_wiki varchar(32) binary
not null;
diff --git a/db_patches/patch-drop_workflow_user.sql
b/db_patches/patch-drop_workflow_user.sql
new file mode 100644
index 0000000..15a0a35
--- /dev/null
+++ b/db_patches/patch-drop_workflow_user.sql
@@ -0,0 +1,5 @@
+ALTER TABLE /*_*/flow_workflow
+ DROP workflow_user_id,
+ DROP workflow_user_ip,
+ DROP workflow_user_wiki;
+
diff --git a/db_patches/patch-remove_usernames.sql
b/db_patches/patch-remove_usernames.sql
index d6625d0..fd2833e 100644
--- a/db_patches/patch-remove_usernames.sql
+++ b/db_patches/patch-remove_usernames.sql
@@ -1,7 +1,4 @@
-ALTER TABLE /*_*/flow_workflow ADD workflow_user_ip varbinary(39) default null;
-UPDATE /*_*/flow_workflow SET workflow_user_ip = null WHERE workflow_user_id
!= 0;
-
ALTER TABLE /*_*/flow_tree_revision ADD tree_orig_user_ip varbinary(39)
default null;
UPDATE /*_*/flow_tree_revision SET tree_orig_user_ip = null WHERE
tree_orig_user_id != 0;
diff --git a/flow.sql b/flow.sql
index 5b24a87..e86c89b 100644
--- a/flow.sql
+++ b/flow.sql
@@ -9,10 +9,6 @@
workflow_title_text varchar(255) binary not null,
workflow_name varchar(255) binary not null,
workflow_last_update_timestamp binary(14) not null,
- -- TODO: check what the new global user ids need for storage
- workflow_user_id bigint unsigned default null,
- workflow_user_ip varbinary(39) default null,
- workflow_user_wiki varchar(32) binary default null,
-- 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,
diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php
index 2fd3428..43a0b03 100644
--- a/includes/Block/TopicList.php
+++ b/includes/Block/TopicList.php
@@ -109,9 +109,9 @@
protected function create() {
$title = $this->workflow->getArticleTitle();
$user = $this->context->getUser();
- $topicWorkflow = Workflow::create( 'topic', $user, $title );
+ $topicWorkflow = Workflow::create( 'topic', $title );
$topicListEntry = TopicListEntry::create( $this->workflow,
$topicWorkflow );
- $topicTitle = PostRevision::create( $topicWorkflow,
$this->submitted['topic'] );
+ $topicTitle = PostRevision::create( $topicWorkflow, $user,
$this->submitted['topic'] );
$firstPost = null;
if ( !empty( $this->submitted['content'] ) ) {
diff --git a/includes/Data/Index/BoardHistoryIndex.php
b/includes/Data/Index/BoardHistoryIndex.php
index c904748..9767f32 100644
--- a/includes/Data/Index/BoardHistoryIndex.php
+++ b/includes/Data/Index/BoardHistoryIndex.php
@@ -2,18 +2,17 @@
namespace Flow\Data\Index;
-use Flow\Container;
use Flow\Data\BufferedCache;
use Flow\Data\ObjectManager;
use Flow\Data\Storage\BoardHistoryStorage;
use Flow\Exception\DataModelException;
-use Flow\Exception\FlowException;
use Flow\Exception\InvalidInputException;
use Flow\Model\AbstractRevision;
use Flow\Model\Header;
use Flow\Model\PostSummary;
use Flow\Model\PostRevision;
use Flow\Model\TopicListEntry;
+use Flow\Model\Workflow;
/**
* Keeps a list of revision ids relevant to the board history bucketed
@@ -118,7 +117,7 @@
return $row['rev_type_id'];
}
- if ( isset( $metadata['workflow'] ) ) {
+ if ( isset( $metadata['workflow'] ) && $metadata['workflow']
instanceof Workflow ) {
$topicId = $metadata['workflow']->getId();
} else {
if ( $object instanceof PostRevision ) {
diff --git a/includes/Data/Index/TopicHistoryIndex.php
b/includes/Data/Index/TopicHistoryIndex.php
index 94ca1d6..01b1659 100644
--- a/includes/Data/Index/TopicHistoryIndex.php
+++ b/includes/Data/Index/TopicHistoryIndex.php
@@ -7,6 +7,7 @@
use Flow\Exception\InvalidInputException;
use Flow\Model\PostRevision;
use Flow\Model\PostSummary;
+use Flow\Model\Workflow;
use Flow\Model\UUID;
use Flow\Repository\TreeRepository;
use MWException;
@@ -68,11 +69,12 @@
/**
* @param PostRevision|PostSummary $object
+ * @param array $metadata
* @return string alphadecimal uuid
* @throws InvalidInputException When $object is not PostRevision or
PostSummary
*/
protected function findTopicRootId( $object, array $metadata ) {
- if ( isset( $metadata['workflow'] ) ) {
+ if ( isset( $metadata['workflow'] ) && $metadata['workflow']
instanceof Workflow ) {
return $metadata['workflow']->getId();
} elseif ( $object instanceof PostRevision ) {
return
$object->getRootPost()->getPostId()->getAlphadecimal();
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index 087ec49..bc6fd75 100644
--- a/includes/Model/PostRevision.php
+++ b/includes/Model/PostRevision.php
@@ -6,6 +6,7 @@
use Flow\Container;
use Flow\Exception\DataModelException;
use Flow\Repository\TreeRepository;
+use Title;
use User;
class PostRevision extends AbstractRevision {
@@ -80,13 +81,12 @@
* an existing post(incl topic root) should use self::reply.
*
* @param Workflow $topic
+ * @param User $user
* @param string $content The title of the topic(they are Collection as
well)
* @return PostRevision
*/
- static public function create( Workflow $topic, $content ) {
- // @todo pass tuple instead?
- $user = $topic->getUserTuple()->createUser();
- $obj = static::newFromId( $topic->getId(), $user, $content );
+ static public function create( Workflow $topic, User $user, $content ) {
+ $obj = static::newFromId( $topic->getId(), $user, $content,
$topic->getArticleTitle() );
$obj->changeType = 'new-post';
// A newly created post has no children, a depth of 0, and
@@ -118,9 +118,10 @@
* @param UUID $uuid
* @param User $user
* @param string $content
+ * @param Title|null $title
* @return PostRevision
*/
- static public function newFromId( UUID $uuid, User $user, $content ) {
+ static public function newFromId( UUID $uuid, User $user, $content,
Title $title = null ) {
$obj = new self;
$obj->revId = UUID::create();
$obj->postId = $uuid;
@@ -130,7 +131,7 @@
$obj->setReplyToId( null ); // not a reply to anything
$obj->prevRevision = null; // no parent revision
- $obj->setContent( $content );
+ $obj->setContent( $content, $title );
return $obj;
}
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index 3ef956d..9f37603 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -58,11 +58,6 @@
protected $titleText;
/**
- * @var UserTuple
- */
- protected $user;
-
- /**
* @var string
*/
protected $lastModified;
@@ -96,10 +91,6 @@
$obj->pageId = $row['workflow_page_id'];
$obj->namespace = (int) $row['workflow_namespace'];
$obj->titleText = $row['workflow_title_text'];
- $obj->user = UserTuple::newFromArray( $row, 'workflow_user_' );
- if ( !$obj->user ) {
- throw new DataModelException( 'Could not create
UserTuple for workflow_user_' );
- }
$obj->lastModified = $row['workflow_last_update_timestamp'];
return $obj;
@@ -117,9 +108,6 @@
'workflow_page_id' => $obj->pageId,
'workflow_namespace' => $obj->namespace,
'workflow_title_text' => $obj->titleText,
- 'workflow_user_wiki' => $obj->user->wiki,
- 'workflow_user_id' => $obj->user->id,
- 'workflow_user_ip' => $obj->user->ip,
'workflow_lock_state' => 0, // unused
'workflow_last_update_timestamp' => $obj->lastModified,
// not used, but set it to empty string so it doesn't
fail in strict mode
@@ -129,12 +117,11 @@
/**
* @param string $type
- * @param User $user
* @param Title $title
* @return Workflow
* @throws DataModelException
*/
- static public function create( $type, User $user, Title $title ) {
+ static public function create( $type, Title $title ) {
// temporary limitation until we implement something more
concrete
if ( !in_array( $type, self::$allowedTypes ) ) {
throw new DataModelException( 'Invalid workflow type
provided: ' . $type, 'process-data' );
@@ -153,7 +140,6 @@
$obj->pageId = $title->getArticleID();
$obj->namespace = $title->getNamespace();
$obj->titleText = $title->getDBkey();
- $obj->user = UserTuple::newFromUser( $user );
$obj->updateLastModified();
return $obj;
@@ -243,26 +229,6 @@
* @return boolean
*/
public function isNew() { return (bool) $this->isNew; }
-
- /**
- * @return UserTuple
- */
- public function getUserTuple() { return $this->user; }
-
- /**
- * @return integer
- */
- public function getUserId() { return $this->user->id; }
-
- /**
- * @return string|null
- */
- public function getUserIp() { return $this->user->ip; }
-
- /**
- * @return string
- */
- public function getUserWiki() { return $this->user->wiki; }
/**
* @return string
diff --git a/includes/WorkflowLoaderFactory.php
b/includes/WorkflowLoaderFactory.php
index fe55c54..8ea2547 100644
--- a/includes/WorkflowLoaderFactory.php
+++ b/includes/WorkflowLoaderFactory.php
@@ -87,7 +87,6 @@
* @throws InvalidDataException
*/
protected function loadWorkflow( \Title $title ) {
- global $wgUser;
$storage = $this->storage->getStorage( 'Workflow' );
$found = $storage->find( array(
@@ -99,7 +98,7 @@
if ( $found ) {
$workflow = reset( $found );
} else {
- $workflow = Workflow::create(
$this->defaultWorkflowName, $wgUser, $title );
+ $workflow = Workflow::create(
$this->defaultWorkflowName, $title );
}
return $workflow;
diff --git a/maintenance/FlowUpdateUserWiki.php
b/maintenance/FlowUpdateUserWiki.php
index 8fd375d..1f20889 100644
--- a/maintenance/FlowUpdateUserWiki.php
+++ b/maintenance/FlowUpdateUserWiki.php
@@ -75,7 +75,6 @@
$this->updateHeader(
$workflow, $row->workflow_wiki );
$this->updateTopicList(
$workflow, $row->workflow_wiki );
}
- $this->updateWorkflow(
$workflow, $row->workflow_wiki );
}
}
} else {
@@ -84,23 +83,6 @@
}
return true;
- }
-
- /**
- * Update workflow
- */
- private function updateWorkflow( $wf, $wiki ) {
- $dbw = Container::get( 'db.factory' )->getDB( DB_MASTER );
- $res = $dbw->update(
- 'flow_workflow',
- array( 'workflow_user_wiki' => $wiki ),
- array( 'workflow_id' => $wf->getId()->getBinary() )
- );
- if ( !$res ) {
- throw new \MWException( 'SQL error in maintenance
script ' . __CLASS__ . '::' . __METHOD__ );
- }
-
- $this->checkForSlave();
}
/**
diff --git a/tests/phpunit/Data/Listener/RecentChangesListenerTest.php
b/tests/phpunit/Data/Listener/RecentChangesListenerTest.php
index f5e02a6..752aaef 100644
--- a/tests/phpunit/Data/Listener/RecentChangesListenerTest.php
+++ b/tests/phpunit/Data/Listener/RecentChangesListenerTest.php
@@ -21,17 +21,16 @@
// expect
NS_MAIN,
// something
- function( $workflow ) {
- return PostRevision::create( $workflow,
'blah blah' );
+ function( $workflow, $user ) {
+ return PostRevision::create( $workflow,
$user, 'blah blah' );
}
),
array(
'Reply recent change goes to the topic',
NS_TOPIC,
- function( $workflow ) {
- $first = PostRevision::create(
$workflow, 'blah blah' );
- $user =
$workflow->getUserTuple()->createUser();
+ function( $workflow, $user ) {
+ $first = PostRevision::create(
$workflow, $user, 'blah blah' );
return $first->reply( $workflow, $user,
'fofofo' );
},
),
@@ -64,9 +63,9 @@
$title = Title::newMainPage();
$user = User::newFromName( '127.0.0.1', false );
- $workflow = Workflow::create( 'topic', $user, $title );
+ $workflow = Workflow::create( 'topic', $title );
- $revision = $init( $workflow );
+ $revision = $init( $workflow, $user );
$rc->onAfterInsert(
$revision,
diff --git a/tests/phpunit/HookTest.php b/tests/phpunit/HookTest.php
index cced1ec..8ea972e 100644
--- a/tests/phpunit/HookTest.php
+++ b/tests/phpunit/HookTest.php
@@ -25,17 +25,17 @@
// can't create Title objects because they can have the wrong
wikiID. Instead we
// pass closures into the test that create the objects within
the correct context.
$newHeader = function() use( $user ) {
- $workflow = Workflow::create( 'discussion', $user,
Title::newMainPage() );
+ $workflow = Workflow::create( 'discussion',
Title::newMainPage() );
return array(
'workflow' => $workflow,
'revision' => Header::create( $workflow, $user,
'header content' ),
);
};
$freshTopic = function() use( $user ) {
- $workflow = Workflow::create( 'topic', $user,
Title::newMainPage() );
+ $workflow = Workflow::create( 'topic',
Title::newMainPage() );
return array(
'workflow' => $workflow,
- 'revision' => PostRevision::create( $workflow,
'some content' ),
+ 'revision' => PostRevision::create( $workflow,
$user, 'some content' ),
);
};
$replyToTopic = function() use( $freshTopic, $user ) {
diff --git a/tests/phpunit/PostRevisionTestCase.php
b/tests/phpunit/PostRevisionTestCase.php
index 592e969..50c6f02 100644
--- a/tests/phpunit/PostRevisionTestCase.php
+++ b/tests/phpunit/PostRevisionTestCase.php
@@ -141,9 +141,6 @@
'workflow_page_id' => 1,
'workflow_namespace' => NS_USER_TALK,
'workflow_title_text' => 'Test',
- 'workflow_user_wiki' => $tuple->wiki,
- 'workflow_user_id' => $tuple->id,
- 'workflow_user_ip' => $tuple->ip,
'workflow_lock_state' => 0,
'workflow_last_update_timestamp' => wfTimestampNow(),
);
diff --git a/tests/phpunit/TemplatingTest.php b/tests/phpunit/TemplatingTest.php
index 10a074c..1517841 100644
--- a/tests/phpunit/TemplatingTest.php
+++ b/tests/phpunit/TemplatingTest.php
@@ -42,8 +42,8 @@
$user = User::newFromName( '127.0.0.1', false );
$title = Title::newMainPage();
- $workflow = Workflow::create( 'topic', $user, $title );
- $topicTitle = PostRevision::create( $workflow, 'some content' );
+ $workflow = Workflow::create( 'topic', $title );
+ $topicTitle = PostRevision::create( $workflow, $user, 'some
content' );
$hidden = $topicTitle->moderate(
$user,
--
To view, visit https://gerrit.wikimedia.org/r/168553
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7c759b46995c045405426239e95f40147e8aaecb
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: Springle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits