EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/117383
Change subject: Combine various history actions
......................................................................
Combine various history actions
Change-Id: I98bb9d96a7c61200c0d43f8ed4d32432b72fb70d
---
M FlowActions.php
M Hooks.php
M includes/Block/BoardHistory.php
M includes/Block/Topic.php
M includes/Data/RootPostLoader.php
M includes/View/Post.php
M includes/View/PostActionMenu.php
M includes/View/Revision.php
M templates/post.html.php
M templates/topic.html.php
M tests/PermissionsTest.php
M tests/RevisionCollectionPermissionsTest.php
12 files changed, 45 insertions(+), 51 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/83/117383/1
diff --git a/FlowActions.php b/FlowActions.php
index f55e735..da7633c 100644
--- a/FlowActions.php
+++ b/FlowActions.php
@@ -375,7 +375,7 @@
),
),
- 'post-history' => array(
+ 'history' => array(
'performs-writes' => false,
'log_type' => false,
'permissions' => array(
@@ -426,7 +426,7 @@
return '';
}
- return $permissions->getPermission(
$previous, 'topic-history' );
+ return $permissions->getPermission(
$previous, 'history' );
}
return '';
@@ -439,15 +439,16 @@
'history' => array() // views don't generate history
),
- // post/topic/board history have exact same config
- 'topic-history' => 'post-history',
- 'board-history' => 'post-history',
+ // deprecated values
// log & all other formatters have same config as history
- 'log' => 'post-history',
- 'recentchanges' => 'post-history',
- 'contributions' => 'post-history',
- 'checkuser' => 'post-history',
+ 'post-history' => 'history',
+ 'topic-history' => 'history',
+ 'board-history' => 'history',
+ 'log' => 'history',
+ 'recentchanges' => 'history',
+ 'contributions' => 'history',
+ 'checkuser' => 'history',
/*
* Backwards compatibility; these are old values that may have made
their
diff --git a/Hooks.php b/Hooks.php
index f5a36f4..da56360 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -228,11 +228,11 @@
if ( $occupationController->isTalkpageOccupied( $title ) ) {
$skname = $template->getSkinName();
- $selected = $template->getRequest()->getVal( 'action' )
== 'board-history';
+ $selected = $template->getRequest()->getVal( 'action' )
== 'history';
$links['views'] = array( array(
'class' => $selected ? 'selected' : '',
'text' => wfMessageFallback(
"$skname-view-history", "history_short" )->text(),
- 'href' => $title->getLocalURL(
'action=board-history' ),
+ 'href' => $title->getLocalURL( 'action=history'
),
) );
// hide all ?action= links unless whitelisted
diff --git a/includes/Block/BoardHistory.php b/includes/Block/BoardHistory.php
index fc83e2b..4654a85 100644
--- a/includes/Block/BoardHistory.php
+++ b/includes/Block/BoardHistory.php
@@ -19,7 +19,7 @@
*/
protected $permissions;
- protected $supportedGetActions = array( 'board-history' );
+ protected $supportedGetActions = array( 'history' );
public function init( $action, $user ) {
parent::init( $action, $user );
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index d2fa451..3600321 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -64,7 +64,7 @@
);
protected $supportedGetActions = array(
- 'view', 'post-history', 'topic-history', 'edit-post',
'edit-title', 'compare-post-revisions',
+ 'view', 'history', 'edit-post', 'edit-title',
'compare-post-revisions',
);
/**
@@ -396,7 +396,7 @@
}
public function render( Templating $templating, array $options, $return
= false ) {
- if ( in_array( $this->action, array( 'post-history',
'topic-history' ) ) ) {
+ if ( $this->action === 'history' ) {
$templating->getOutput()->addModuleStyles( array(
'ext.flow.history' ) );
$templating->getOutput()->addModules( array(
'ext.flow.history' ) );
} else {
@@ -407,10 +407,11 @@
$prefix = '';
switch( $this->action ) {
- case 'post-history':
- return $prefix . $this->renderPostHistory( $templating,
$options, $return );
+ case 'history':
+ if ( isset( $options['postId'] ) ) {
+ return $prefix . $this->renderPostHistory(
$templating, $options, $return );
+ }
- case 'topic-history':
$history = $this->loadTopicHistory();
$root = $this->loadRootPost();
if ( !$root ) {
@@ -702,7 +703,7 @@
/** @var PostRevision $revision */
// only check against the specific revision,
ignoring the most recent
- if ( !$this->permissions->isAllowed( $revision,
'post-history' ) ) {
+ if ( !$this->permissions->isAllowed( $revision,
'history' ) ) {
unset( $history[$i] );
}
}
@@ -818,7 +819,7 @@
/** @var PostRevision $revision */
// only check against the specific revision,
ignoring the most recent
- if ( !$this->permissions->isAllowed( $revision,
'topic-history' ) ) {
+ if ( !$this->permissions->isAllowed( $revision,
'history' ) ) {
unset( $history[$i] );
}
}
diff --git a/includes/Data/RootPostLoader.php b/includes/Data/RootPostLoader.php
index 6817607..cb4815b 100644
--- a/includes/Data/RootPostLoader.php
+++ b/includes/Data/RootPostLoader.php
@@ -53,7 +53,7 @@
} elseif( $rootId->equals( $post->getPostId() ) ) {
$res['root'] = $post;
} else {
- die( 'Unmatched: ' .
$post->getPostId()->getAlphadecimal() );
+ throw new InvalidDataException( 'Unmatched: ' .
$post->getPostId()->getAlphadecimal() );
}
}
// The above doesn't catch this condition
diff --git a/includes/View/Post.php b/includes/View/Post.php
index 1d0c344..1e162f7 100644
--- a/includes/View/Post.php
+++ b/includes/View/Post.php
@@ -115,7 +115,7 @@
public function postHistoryLink( $blockName ) {
return $this->actions->actionUrl(
- 'post-history',
+ 'history',
array( $blockName . '_postId' =>
$this->post->getPostId()->getAlphadecimal() )
);
}
diff --git a/includes/View/PostActionMenu.php b/includes/View/PostActionMenu.php
index 760a7c6..03b7e9e 100644
--- a/includes/View/PostActionMenu.php
+++ b/includes/View/PostActionMenu.php
@@ -58,7 +58,11 @@
if ( !$this->permissions->isAllowed( $this->post, $action ) ) {
return false;
}
- $data = array( $this->block->getName() . '_postId' =>
$this->post->getPostId()->getAlphadecimal() );
+ if ( $this->post->isTopicTitle() ) {
+ $data = array();
+ } else {
+ $data = array( $this->block->getName() . '_postId' =>
$this->post->getPostId()->getAlphadecimal() );
+ }
if ( $this->getMethod( $action ) === 'POST' ) {
return $this->postAction( $action, $data, $content,
$class );
} else {
diff --git a/includes/View/Revision.php b/includes/View/Revision.php
index 6c815b8..aa9b27f 100644
--- a/includes/View/Revision.php
+++ b/includes/View/Revision.php
@@ -355,7 +355,7 @@
$historyLink = $this->templating->getUrlGenerator()
->generateUrl(
$this->block->getWorkflow(),
- 'board-history'
+ 'history'
);
$headerMsg = wfMessage( 'flow-compare-revisions-header-header' )
->params(
@@ -380,7 +380,7 @@
public function getSingleViewHeader() {
$historyLink =
$this->templating->getUrlGenerator()->generateUrl(
$this->block->getWorkflow(),
- 'board-history'
+ 'history'
);
$compareLink = $this->getDiffLinkAgainstPrevious( $this->block
);
@@ -535,7 +535,7 @@
$historyLink = $this->templating->getUrlGenerator()
->generateUrl(
$this->block->getWorkflow(),
- 'post-history',
+ 'history',
array(
$this->block->getName().'_postId' =>
$newRevision->getPostId()->getAlphadecimal()
)
@@ -565,7 +565,7 @@
public function getSingleViewHeader() {
$historyLink =
$this->templating->getUrlGenerator()->generateUrl(
$this->block->getWorkflow(),
- 'post-history',
+ 'history',
array(
$this->block->getName().'_postId' =>
$this->revision->getPostId()->getAlphadecimal(),
)
diff --git a/templates/post.html.php b/templates/post.html.php
index 802732b..0a98b41 100644
--- a/templates/post.html.php
+++ b/templates/post.html.php
@@ -101,7 +101,7 @@
<?php
endif;
- if ( $postView->actions()->isAllowedAny( 'hide-post',
'delete-post', 'suppress-post', 'restore-post', 'view', 'post-history' ) ): ?>
+ if ( $postView->actions()->isAllowedAny( 'history',
'hide-post', 'delete-post', 'suppress-post', 'restore-post', 'view' ) ): ?>
<div class="flow-tipsy flow-actions">
<a class="flow-tipsy-link" href="#"
title="<?php echo wfMessage( 'flow-post-actions' )->escaped(); ?>"><?php echo
wfMessage( 'flow-post-actions' )->escaped(); ?></a>
<div class="flow-tipsy-flyout">
@@ -125,7 +125,7 @@
// History link
if ( $post->getPrevRevisionId()
) {
$historyButton =
$postActionMenu->getButton(
- 'post-history',
+ 'history',
wfMessage(
'flow-post-action-post-history' )->escaped(),
'mw-ui-button
flow-action-post-history-link'
);
diff --git a/templates/topic.html.php b/templates/topic.html.php
index 97fde48..0533a39 100644
--- a/templates/topic.html.php
+++ b/templates/topic.html.php
@@ -94,7 +94,7 @@
);
endif ?>
</div>
- <?php if ( $postActionMenu->isAllowedAny( 'view', 'hide-topic',
'delete-topic', 'suppress-topic', 'restore-topic', 'edit-title',
'topic-history' ) ): ?>
+ <?php if ( $postActionMenu->isAllowedAny( 'history', 'view',
'hide-topic', 'delete-topic', 'suppress-topic', 'restore-topic', 'edit-title' )
): ?>
<div class="flow-tipsy flow-actions">
<a class="flow-tipsy-link" href="#"><?php echo
wfMessage( 'flow-topic-actions' )->escaped(); ?></a>
<div class="flow-tipsy-flyout">
@@ -113,9 +113,9 @@
'mw-ui-button
flow-hide-topic-link'
), '</li>';
} ?>
- <?php if ( $postActionMenu->isAllowed(
'topic-history' ) ) {
+ <?php if ( $postActionMenu->isAllowed(
'history' ) ) {
echo '<li
class="flow-action-topic-history">', $postActionMenu->getButton(
- 'topic-history',
+ 'history',
wfMessage(
'flow-topic-action-history' )->escaped(),
'mw-ui-button
flow-action-topic-history-link'
), '</li>';
diff --git a/tests/PermissionsTest.php b/tests/PermissionsTest.php
index 891936c..fd90183 100644
--- a/tests/PermissionsTest.php
+++ b/tests/PermissionsTest.php
@@ -117,9 +117,7 @@
array( $this->blockedUser(), $this->topic(),
'suppress-topic', false ),
array( $this->blockedUser(), $this->post(),
'restore-post', false ),
array( $this->blockedUser(), $this->topic(),
'restore-topic', false ),
- array( $this->blockedUser(), $this->post(),
'post-history', true ),
- array( $this->blockedUser(), $this->topic(),
'topic-history', true ),
- array( $this->blockedUser(), $this->topic(),
'board-history', true ),
+ array( $this->blockedUser(), $this->post(), 'history',
true ),
array( $this->blockedUser(), $this->post(), 'view',
true ),
array( $this->blockedUser(), $this->post(), 'reply',
false ),
@@ -137,9 +135,7 @@
array( $this->anonUser(), $this->topic(),
'suppress-topic', false ),
array( $this->anonUser(), $this->post(),
'restore-post', false ),
array( $this->anonUser(), $this->topic(),
'restore-topic', false ),
- array( $this->anonUser(), $this->post(),
'post-history', true ),
- array( $this->anonUser(), $this->topic(),
'topic-history', true ),
- array( $this->anonUser(), $this->topic(),
'board-history', true ),
+ array( $this->anonUser(), $this->post(), 'history',
true ),
array( $this->anonUser(), $this->post(), 'view', true ),
array( $this->anonUser(), $this->post(), 'reply', true
),
@@ -157,9 +153,7 @@
array( $this->unconfirmedUser(), $this->topic(),
'suppress-topic', false ),
array( $this->unconfirmedUser(), $this->post(),
'restore-post', false ), // $this->post is not hidden
array( $this->unconfirmedUser(), $this->topic(),
'restore-topic', false ), // $this->topic is not hidden
- array( $this->unconfirmedUser(), $this->post(),
'post-history', true ),
- array( $this->unconfirmedUser(), $this->topic(),
'topic-history', true ),
- array( $this->unconfirmedUser(), $this->topic(),
'board-history', true ),
+ array( $this->unconfirmedUser(), $this->post(),
'history', true ),
array( $this->unconfirmedUser(), $this->post(), 'view',
true ),
array( $this->unconfirmedUser(), $this->post(),
'reply', true ),
@@ -187,9 +181,7 @@
array( $this->confirmedUser(), $this->topic(),
'suppress-topic', false ),
array( $this->confirmedUser(), $this->post(),
'restore-post', false ), // $this->post is not hidden
array( $this->confirmedUser(), $this->topic(),
'restore-topic', false ), // $this->topic is not hidden
- array( $this->confirmedUser(), $this->post(),
'post-history', true ),
- array( $this->confirmedUser(), $this->topic(),
'topic-history', true ),
- array( $this->confirmedUser(), $this->topic(),
'board-history', true ),
+ array( $this->confirmedUser(), $this->post(),
'history', true ),
array( $this->confirmedUser(), $this->post(), 'view',
true ),
array( $this->confirmedUser(), $this->post(), 'reply',
true ),
array( $this->confirmedUser(), $this->hiddenPost(),
'restore-post', true ),
@@ -213,9 +205,7 @@
array( $this->sysopUser(), $this->topic(),
'suppress-topic', false ),
array( $this->sysopUser(), $this->post(),
'restore-post', false ), // $this->post is not hidden
array( $this->sysopUser(), $this->topic(),
'restore-topic', false ), // $this->topic is not hidden
- array( $this->sysopUser(), $this->post(),
'post-history', true ),
- array( $this->sysopUser(), $this->topic(),
'topic-history', true ),
- array( $this->sysopUser(), $this->topic(),
'board-history', true ),
+ array( $this->sysopUser(), $this->topic(), 'history',
true ),
array( $this->sysopUser(), $this->post(), 'view', true
),
array( $this->sysopUser(), $this->post(), 'reply', true
),
array( $this->sysopUser(), $this->hiddenPost(),
'restore-post', true ),
@@ -239,9 +229,7 @@
array( $this->oversightUser(), $this->topic(),
'suppress-topic', true ),
array( $this->oversightUser(), $this->post(),
'restore-post', false ), // $this->post is not hidden
array( $this->oversightUser(), $this->topic(),
'restore-topic', false ), // $this->topic is not hidden
- array( $this->oversightUser(), $this->post(),
'post-history', true ),
- array( $this->oversightUser(), $this->topic(),
'topic-history', true ),
- array( $this->oversightUser(), $this->topic(),
'board-history', true ),
+ array( $this->oversightUser(), $this->post(),
'history', true ),
array( $this->oversightUser(), $this->post(), 'view',
true ),
array( $this->oversightUser(), $this->post(), 'reply',
true ),
array( $this->oversightUser(), $this->hiddenPost(),
'restore-post', true ),
diff --git a/tests/RevisionCollectionPermissionsTest.php
b/tests/RevisionCollectionPermissionsTest.php
index 604f423..e596f4e 100644
--- a/tests/RevisionCollectionPermissionsTest.php
+++ b/tests/RevisionCollectionPermissionsTest.php
@@ -149,11 +149,11 @@
) ),
// bug 61715
- array( $this->confirmedUser(), 'topic-history', array(
+ array( $this->confirmedUser(), 'history', array(
array( 'new-post' => false ),
array( 'suppress-post' => false ),
) ),
- array( $this->confirmedUser(), 'topic-history', array(
+ array( $this->confirmedUser(), 'history', array(
array( 'new-post' => true ),
array( 'suppress-post' => false ),
array( 'restore-post' => false ),
--
To view, visit https://gerrit.wikimedia.org/r/117383
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I98bb9d96a7c61200c0d43f8ed4d32432b72fb70d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits