jenkins-bot has submitted this change and it was merged.
Change subject: Change rev_comment to rev_change_type
......................................................................
Change rev_comment to rev_change_type
Also adjusts reference to "comments" to instead refer to "change types"
and updates the cache keys used for Summary(header) and post revision storage
to bust any caches containing the prior rev_comment data.
Change-Id: Ib0afc042f35677f2566a1f6a9223b9e89316a352
---
M Hooks.php
M container.php
A db_patches/patch-rev_change_type.sql
A db_patches/patch-rev_change_type.sqlite.sql
M flow.sql
M includes/Block/Topic.php
M includes/Data/RecentChanges.php
M includes/Model/AbstractRevision.php
M includes/Model/Header.php
M includes/Model/PostRevision.php
M includes/RecentChanges/Formatter.php
M templates/post-history.html.php
M templates/topic-history.html.php
13 files changed, 92 insertions(+), 36 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Hooks.php b/Hooks.php
index a12c21a..affc1b6 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -29,12 +29,15 @@
$updater->addExtensionField( 'flow_revision',
'rev_last_edit_id', "$dir/db_patches/patch-revision_last_editor.sql" );
if ( $updater->getDB()->getType() === 'sqlite' ) {
$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" );
} else {
// sqlite doesn't support alter table change, it also
considers all types the same so
// this patch doesn't matter to it.
$updater->modifyExtensionField( 'flow_subscription',
'subscription_user_id', "$dir/db_patches/patch-subscription_user_id.sql" );
// renames columns, alternate patch is above for sqlite
$updater->modifyExtensionField(
'flow_summary_revision', 'summary_workflow_id',
"$dir/db_patches/patch-summary2header.sql" );
+ // 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" );
}
$updater->addExtensionIndex( 'flow_workflow',
'flow_workflow_lookup', "$dir/db_patches/patch-workflow_lookup_idx.sql" );
diff --git a/container.php b/container.php
index 6fe5b42..1681fc3 100644
--- a/container.php
+++ b/container.php
@@ -122,7 +122,7 @@
$pk = new UniqueFeatureIndex(
$cache, $storage,
- 'flow_header:pk', array( 'rev_id' )
+ 'flow_header:v2:pk', array( 'rev_id' )
);
$workflowIndexOptions = array(
'sort' => 'rev_id',
@@ -188,7 +188,7 @@
$treeRepo = $c['repository.tree'];
$mapper = BasicObjectMapper::model( 'Flow\\Model\\PostRevision' );
$storage = new PostRevisionStorage( $c['db.factory'],
$wgFlowExternalStore, $treeRepo );
- $pk = new UniqueFeatureIndex( $cache, $storage, 'flow_revision:pk',
array( 'rev_id' ) );
+ $pk = new UniqueFeatureIndex( $cache, $storage, 'flow_revision:v2:pk',
array( 'rev_id' ) );
$indexes = array(
$pk,
// revision history
diff --git a/db_patches/patch-rev_change_type.sql
b/db_patches/patch-rev_change_type.sql
new file mode 100644
index 0000000..63cd28f
--- /dev/null
+++ b/db_patches/patch-rev_change_type.sql
@@ -0,0 +1,2 @@
+-- Changes rev_comment to rev_change_type
+ALTER TABLE /*_*/flow_revision CHANGE rev_comment rev_change_type
varbinary(255) null;
diff --git a/db_patches/patch-rev_change_type.sqlite.sql
b/db_patches/patch-rev_change_type.sqlite.sql
new file mode 100644
index 0000000..396f1cd
--- /dev/null
+++ b/db_patches/patch-rev_change_type.sqlite.sql
@@ -0,0 +1,50 @@
+
+
+ALTER TABLE /*_*/flow_revision RENAME TO /*_*/temp_flow_revision_change_type;
+
+CREATE TABLE /*_*/flow_revision (
+ -- UID::newTimestampedUID128()
+ rev_id binary(16) not null,
+ -- What kind of revision is this: tree/summary/etc.
+ rev_type varchar(16) binary not null,
+ -- user id creating the revision
+ rev_user_id bigint unsigned not null,
+ -- name of user creating the revision, or ip address if anon
+ -- TODO: global user logins will obviate the need for this, but a round
trip
+ -- will be needed to map from rev_user_id -> user name
+ rev_user_text varchar(255) binary not null default '',
+ -- rev_id of parent or null if no previous revision
+ rev_parent_id binary(16),
+ -- comma separated set of ascii flags.
+ rev_flags tinyblob not null,
+ -- content of the revision
+ rev_content mediumblob not null,
+ -- the type of change that was made. MW message key.
+ -- formerly rev_comment
+ rev_change_type varbinary(255) null,
+ -- current moderation state
+ rev_mod_state varchar(32) binary not null,
+ -- moderated by who?
+ rev_mod_user_id bigint unsigned,
+ rev_mod_user_text varchar(255) binary,
+ rev_mod_timestamp varchar(14) binary,
+
+ -- track who made the most recent content edit
+ rev_last_edit_id binary(16) null,
+ rev_edit_user_id bigint unsigned,
+ rev_edit_user_text varchar(255) binary,
+
+ PRIMARY KEY (rev_id)
+) /*$wgDBTableOptions*/;
+
+INSERT INTO flow_revision
+ (rev_id, rev_type, rev_user_id, rev_user_text, rev_parent_id,
rev_flags, rev_content, rev_change_type, rev_mod_state, rev_mod_user_id,
rev_mod_user_text, rev_mod_timestamp, rev_last_edit_id, rev_edit_user_id,
rev_edit_user_text )
+SELECT
+ rev_id, rev_type, rev_user_id, rev_user_text, rev_parent_id, rev_flags,
rev_content, rev_comment, rev_mod_state, rev_mod_user_id, rev_mod_user_text,
rev_mod_timestamp, rev_last_edit_id, rev_edit_user_id, rev_edit_user_text
+FROM
+ /*_*/temp_flow_revision_change_type;
+
+DROP TABLE temp_flow_revision_change_type;
+
+CREATE UNIQUE INDEX /*i*/flow_revision_unique_parent ON
+ /*_*/flow_revision (rev_parent_id);
diff --git a/flow.sql b/flow.sql
index 66ae34b..d50ca28 100644
--- a/flow.sql
+++ b/flow.sql
@@ -112,8 +112,9 @@
rev_flags tinyblob not null,
-- content of the revision
rev_content mediumblob not null,
- -- comment attached to revision's flag change
- rev_comment varchar(255) binary null,
+ -- the type of change that was made. MW message key.
+ -- formerly rev_comment
+ rev_change_type varbinary(255) null,
-- current moderation state
rev_mod_state varchar(32) binary not null,
-- moderated by who?
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 491d516..0696699 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -428,7 +428,7 @@
$output[] = array(
'revision-id' =>
$revision->getRevisionId()->getHex(),
'revision-author' => $revision->getUserText(),
- 'revision-comment' => $revision->getComment(),
+ 'revision-change-type' =>
$revision->getChangeType(),
);
}
diff --git a/includes/Data/RecentChanges.php b/includes/Data/RecentChanges.php
index 2e43b3c..2effd74 100644
--- a/includes/Data/RecentChanges.php
+++ b/includes/Data/RecentChanges.php
@@ -85,7 +85,7 @@
}
$this->insert(
- $object->getComment(),
+ $object->getChangeType(),
$row,
$workflow,
$object->getRevisionId(),
@@ -119,7 +119,7 @@
}
$this->insert(
- $object->getComment(),
+ $object->getChangeType(),
$row,
$workflow,
$object->getRevisionId(),
diff --git a/includes/Model/AbstractRevision.php
b/includes/Model/AbstractRevision.php
index e2f10da..33f0f29 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -24,10 +24,10 @@
'content' => null,
// This is the bit of text rendered instead of the post
creator
'usertext' => null,
- // i18n key for history and recentchanges comment
- 'comment' => 'flow-rev-message-restored-post',
// Whether or not to create a new revision when setting
this state
'new-revision' => true,
+ // i18n key for history and recentchanges
+ 'change-type' => 'flow-rev-message-restored-post',
),
self::MODERATED_HIDDEN => array(
// The permission needed from User::isAllowed to see
and create new revisions
@@ -37,10 +37,10 @@
'content' => 'flow-post-hidden-by',
// This is the bit of text rendered instead of the post
creator
'usertext' => 'flow-rev-message-hid-post',
- // i18n key for history and recentchanges comment
- 'comment' => 'flow-rev-message-hid-post',
// Whether or not to create a new revision when setting
this state
'new-revision' => true,
+ // i18n key for history and recentchanges
+ 'change-type' => 'flow-rev-message-hid-post',
),
self::MODERATED_DELETED => array(
// The permission needed from User::isAllowed to see
and create new revisions
@@ -49,10 +49,10 @@
'content' => 'flow-post-deleted-by',
// This is the bit of text rendered instead of the post
creator
'usertext' => 'flow-rev-message-deleted-post',
- // i18n key for history and recentchanges comment
- 'comment' => 'flow-rev-message-deleted-post',
// Whether or not to create a new revision when setting
this state
'new-revision' => false,
+ // i18n key for history and recentchanges
+ 'change-type' => 'flow-rev-message-deleted-post',
),
self::MODERATED_CENSORED => array(
// The permission needed from User::isAllowed to see
and create new revisions
@@ -61,10 +61,10 @@
'content' => 'flow-post-censored-by',
// This is the bit of text rendered instead of the post
creator
'usertext' => 'flow-rev-message-censored-post',
- // i18n key for history and recentchanges comment
- 'comment' => 'flow-rev-message-censored-post',
// Whether or not to create a new revision when setting
this state
'new-revision' => false,
+ // i18n key for history and recentchanges
+ 'change-type' => 'flow-rev-message-censored-post',
),
);
@@ -81,7 +81,7 @@
// An i18n message key indicating what kind of change this revision is
// primary use case is the a revision history list.
// TODO: i18n key may be too limiting, consider allowing custom
revision comments
- protected $comment;
+ protected $changeType;
// UUID of the revision prior to this one, or null if this is first
revision
protected $prevRevision;
@@ -117,7 +117,7 @@
$obj->userId = $row['rev_user_id'];
$obj->userText = $row['rev_user_text'];
$obj->prevRevision = UUID::create( $row['rev_parent_id'] );
- $obj->comment = $row['rev_comment'];
+ $obj->changeType = $row['rev_change_type'];
$obj->flags = array_filter( explode( ',', $row['rev_flags'] ) );
$obj->content = $row['rev_content'];
// null if external store is not being used
@@ -143,7 +143,7 @@
'rev_user_id' => $obj->userId,
'rev_user_text' => $obj->userText,
'rev_parent_id' => $obj->prevRevision ?
$obj->prevRevision->getBinary() : null,
- 'rev_comment' => $obj->comment,
+ 'rev_change_type' => $obj->changeType,
'rev_type' => $obj->getRevisionType(),
'rev_content' => $obj->content,
@@ -172,17 +172,17 @@
$obj->userId = $user->getId();
$obj->userText = $user->getName();
$obj->prevRevision = $this->revId;
- $obj->comment = '';
+ $obj->changeType = '';
return $obj;
}
/**
* Create the next revision with new content
*/
- public function newNextRevision( User $user, $content, $comment ) {
+ public function newNextRevision( User $user, $content, $changeType ) {
$obj = $this->newNullRevision( $user );
$obj->setNextContent( $user, $content );
- $obj->comment = $comment;
+ $obj->changeType = $changeType;
return $obj;
}
@@ -198,7 +198,7 @@
return $keys[max( $aPos, $bPos )];
}
- public function moderate( User $user, $state, $comment = null ) {
+ public function moderate( User $user, $state, $changeType = null ) {
if ( !isset( self::$perms[$state] ) ) {
wfDebugLog( __CLASS__, __FUNCTION__ . ': Provided
moderation state does not exist : ' . $state );
return null;
@@ -227,10 +227,10 @@
$obj->moderatedByUserText = $user->getName();
$obj->moderationTimestamp = wfTimestampNow();
}
- if ( $comment === null && isset(
self::$perms[$state]['comment'] ) ) {
- $obj->comment = self::$perms[$state]['comment'];
+ if ( $changeType === null && isset(
self::$perms[$state]['change-type'] ) ) {
+ $obj->changeType = self::$perms[$state]['change-type'];
} else {
- $obj->comment = $comment;
+ $obj->changeType = $changeType;
}
return $obj;
}
@@ -409,8 +409,8 @@
return $this->prevRevision;
}
- public function getComment() {
- return $this->comment;
+ public function getChangeType() {
+ return $this->changeType;
}
public function getModerationState() {
diff --git a/includes/Model/Header.php b/includes/Model/Header.php
index 6990003..a321f90 100644
--- a/includes/Model/Header.php
+++ b/includes/Model/Header.php
@@ -7,7 +7,7 @@
class Header extends AbstractRevision {
protected $workflowId;
- static public function create( Workflow $workflow, User $user,
$content, $comment = 'flow-create-header' ) {
+ static public function create( Workflow $workflow, User $user,
$content, $changeType = 'flow-create-header' ) {
$obj = new self;
$obj->revId = UUID::create();
$obj->workflowId = $workflow->getId();
@@ -15,7 +15,7 @@
$obj->userText = $user->getName();
$obj->prevRevision = null; // no prior revision
$obj->setContent( $content );
- $obj->comment = $comment;
+ $obj->changeType = $changeType;
return $obj;
}
diff --git a/includes/Model/PostRevision.php b/includes/Model/PostRevision.php
index d5d4fe7..f5fabcc 100644
--- a/includes/Model/PostRevision.php
+++ b/includes/Model/PostRevision.php
@@ -30,7 +30,7 @@
$obj->origCreateTime = wfTimestampNow();
$obj->replyToId = null; // not a reply to anything
$obj->prevRevId = null; // no parent revision
- $obj->comment = 'flow-rev-message-new-post';
+ $obj->changeType = 'flow-rev-message-new-post';
$obj->setContent( $content );
return $obj;
}
@@ -61,7 +61,7 @@
);
}
- public function reply( User $user, $content, $comment =
'flow-rev-message-reply' ) {
+ public function reply( User $user, $content, $changeType =
'flow-rev-message-reply' ) {
$reply = new self;
// No great reason to create two uuid's, a post and its first
revision can share a uuid
$reply->revId = $reply->postId = UUID::create();
@@ -70,7 +70,7 @@
$reply->origCreateTime = wfTimestampNow();
$reply->setContent( $content );
$reply->replyToId = $this->postId;
- $reply->comment = $comment;
+ $reply->changeType = $changeType;
return $reply;
}
diff --git a/includes/RecentChanges/Formatter.php
b/includes/RecentChanges/Formatter.php
index 6b2652d..593753a 100644
--- a/includes/RecentChanges/Formatter.php
+++ b/includes/RecentChanges/Formatter.php
@@ -51,7 +51,7 @@
. ' '
. $this->userLinks( $cl, $rc->getAttribute(
'rc_user_id' ), $rc->getAttribute( 'rc_user_text' ) )
. ' '
- . $this->getComment( $changeData );
+ . $this->getActionDescription( $changeData );
return $line;
}
@@ -173,7 +173,7 @@
);
}
- public function getComment( array $changeData ) {
+ public function getActionDescription( array $changeData ) {
$msg = wfMessage( $changeData['type'] )->text();
if ( isset( $changeData['topic'] ) ) {
diff --git a/templates/post-history.html.php b/templates/post-history.html.php
index 7880828..9a08697 100644
--- a/templates/post-history.html.php
+++ b/templates/post-history.html.php
@@ -6,7 +6,7 @@
echo '<li>'
. $revision->getRevisionId()->getHex() . ' : '
. $revision->getUserText() . ' : '
- . $revision->getComment()
+ . $revision->getChangeType()
. '</li>';
}
echo '</ul>';
diff --git a/templates/topic-history.html.php b/templates/topic-history.html.php
index 1ca9350..9421d66 100644
--- a/templates/topic-history.html.php
+++ b/templates/topic-history.html.php
@@ -6,7 +6,7 @@
echo '<li>'
. $revision->getRevisionId()->getHex() . ' : '
. $revision->getUserText() . ' : '
- . wfMessage( $revision->getComment() )->parse()
+ . wfMessage( $revision->getChangeType() )->parse()
. '</li>';
}
echo '</ul>';
--
To view, visit https://gerrit.wikimedia.org/r/88398
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib0afc042f35677f2566a1f6a9223b9e89316a352
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits