jenkins-bot has submitted this change and it was merged. Change subject: Combine various history actions ......................................................................
Combine various history actions Resubmit b/c of buggy tests 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, 52 insertions(+), 55 deletions(-) Approvals: Matthias Mullie: Looks good to me, approved jenkins-bot: Verified diff --git a/FlowActions.php b/FlowActions.php index fdb1740..585fd8d 100644 --- a/FlowActions.php +++ b/FlowActions.php @@ -418,7 +418,7 @@ ), ), - 'post-history' => array( + 'history' => array( 'performs-writes' => false, 'log_type' => false, 'rc_insert' => false, // won't even be called, actually; only for writes @@ -463,14 +463,14 @@ * is the same as the moderation (e.g. if user can't see * suppress actions, he can't see restores from suppress. */ - if ( $revision->getChangeType() == 'restore-post' ) { + if ( strpos( $revision->getChangeType(), 'restore-' ) === 0 ) { $previous = $collection->getPrevRevision( $revision ); if ( $previous === null || $previous->getModerationState() === AbstractRevision::MODERATED_NONE ) { return ''; } - return $permissions->getPermission( $previous, 'topic-history' ); + return $permissions->getPermission( $previous, 'history' ); } return ''; @@ -483,15 +483,11 @@ 'history' => array() // views don't generate history ), - // post/topic/board history have exact same config - 'topic-history' => 'post-history', - 'board-history' => 'post-history', - // log & all other formatters have same config as history - 'log' => 'post-history', - 'recentchanges' => 'post-history', - 'contributions' => 'post-history', - 'checkuser' => 'post-history', + 'log' => 'history', + 'recentchanges' => 'history', + 'contributions' => 'history', + 'checkuser' => 'history', /* * Backwards compatibility; these are old values that may have made their @@ -527,4 +523,10 @@ */ 'censor-post' => 'suppress-post', 'censor-topic' => 'suppress-topic', + /* + * Backwards compatibility for old (separated) history actions + */ + 'post-history' => 'history', + 'topic-history' => 'history', + 'board-history' => 'history', ); diff --git a/Hooks.php b/Hooks.php index 73b44d4..0c0e511 100644 --- a/Hooks.php +++ b/Hooks.php @@ -276,11 +276,11 @@ if ( self::$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 ebe809d..0fdee39 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 559e79b..6c4c2bb 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', ); /** @@ -401,7 +401,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 { @@ -412,15 +412,18 @@ $prefix = ''; switch( $this->action ) { - case 'post-history': - return $prefix . $this->renderPostHistory( $templating, $options, $return ); - - case 'topic-history': - $history = $this->loadTopicHistory(); + case 'history': $root = $this->loadRootPost(); if ( !$root ) { return ''; } + + // BC: old history links used to also have postId for topic history + if ( isset( $options['postId'] ) && !$root->getPostId()->equals( UUID::create( $options['postId'] ) ) ) { + return $prefix . $this->renderPostHistory( $templating, $options, $return ); + } + + $history = $this->loadTopicHistory(); return $prefix . $templating->render( "flow:topic-history.html.php", array( 'block' => $this, @@ -708,7 +711,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] ); } } @@ -824,7 +827,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 5fd13ef..8795e3c 100644 --- a/includes/View/Post.php +++ b/includes/View/Post.php @@ -119,7 +119,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 90dd99a..de73b2b 100644 --- a/includes/View/Revision.php +++ b/includes/View/Revision.php @@ -373,7 +373,7 @@ $historyLink = $this->templating->getUrlGenerator() ->generateUrl( $this->block->getWorkflow(), - 'board-history' + 'history' ); $headerMsg = wfMessage( 'flow-compare-revisions-header-header' ) ->params( @@ -398,7 +398,7 @@ public function getSingleViewHeader() { $historyLink = $this->templating->getUrlGenerator()->generateUrl( $this->block->getWorkflow(), - 'board-history' + 'history' ); $compareLink = $this->getDiffLinkAgainstPrevious( $this->block ); @@ -570,7 +570,7 @@ $historyLink = $this->templating->getUrlGenerator() ->generateUrl( $this->block->getWorkflow(), - 'post-history', + 'history', array( $this->block->getName().'_postId' => $newRevision->getPostId()->getAlphadecimal() ) @@ -600,7 +600,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 2d321b5..9c77872 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"> @@ -121,7 +121,7 @@ // History link if ( $post->getPrevRevisionId() ) { $historyButton = $postActionMenu->getButton( - 'post-history', + 'history', wfMessage( 'flow-post-action-post-history' )->escaped(), 'mw-ui-button mw-ui-quiet flow-action-post-history-link' ); diff --git a/templates/topic.html.php b/templates/topic.html.php index c471299..c2dc40b 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 mw-ui-quiet flow-action-permalink-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 mw-ui-quiet flow-action-topic-history-link' ), '</li>'; diff --git a/tests/PermissionsTest.php b/tests/PermissionsTest.php index f7d6ffa..a8d0d60 100644 --- a/tests/PermissionsTest.php +++ b/tests/PermissionsTest.php @@ -116,9 +116,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 ), @@ -136,9 +134,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 ), @@ -156,9 +152,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 ), @@ -186,9 +180,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 ), @@ -212,9 +204,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 ), @@ -238,9 +228,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 012b131..725f852 100644 --- a/tests/RevisionCollectionPermissionsTest.php +++ b/tests/RevisionCollectionPermissionsTest.php @@ -135,11 +135,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: merged Gerrit-Change-Id: I98bb9d96a7c61200c0d43f8ed4d32432b72fb70d Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits