Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/193094
Change subject: Fix link targets in usenewrc
......................................................................
Fix link targets in usenewrc
Depends on new hook being introduced in core:
Ib32fb9552b80f9581d89b3b47da6e5d32e3d84a3
Bug: T72513
Change-Id: I127b64d1b97cb981a8a8c82c836cd97db62cc918
---
M Flow.php
M Hooks.php
M includes/Formatter/RecentChanges.php
3 files changed, 83 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/94/193094/1
diff --git a/Flow.php b/Flow.php
index ecaecee..8a09e39 100644
--- a/Flow.php
+++ b/Flow.php
@@ -63,6 +63,7 @@
$wgHooks['OldChangesListRecentChangesLine'][] =
'FlowHooks::onOldChangesListRecentChangesLine';
$wgHooks['ChangesListInsertArticleLink'][] =
'FlowHooks::onChangesListInsertArticleLink';
$wgHooks['ChangesListInitRows'][] = 'FlowHooks::onChangesListInitRows';
+$wgHooks['EnhancedChangesList::getLogText'][] = 'FlowHooks::onGetLogText';
$wgHooks['SkinTemplateNavigation::Universal'][] =
'FlowHooks::onSkinTemplateNavigation';
$wgHooks['Article::MissingArticleConditions'][] =
'FlowHooks::onMissingArticleConditions';
$wgHooks['SpecialWatchlistGetNonRevisionTypes'][] =
'FlowHooks::onSpecialWatchlistGetNonRevisionTypes';
diff --git a/Hooks.php b/Hooks.php
index 3a853c6..19aec11 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -345,6 +345,54 @@
return true;
}
+ /**
+ * Alter the enhanced RC links: (n changes | history)
+ * The default diff links are incorrect!
+ *
+ * @param EnhancedChangesList $changesList
+ * @param array $links
+ * @param RecentChange[] $block
+ * @return bool
+ */
+ public static function onGetLogText( $changesList, &$links, $block ) {
+ $rc = $block[0];
+
+ // quit if non-flow
+ $source = $block[0]->getAttribute( 'rc_source' );
+ if ( $source === null ) {
+ $rcType = (int) $block[0]->getAttribute( 'rc_type' );
+ if ( $rcType !== RC_FLOW ) {
+ return true;
+ }
+ } elseif ( $source !==
Flow\Data\Listener\RecentChangesListener::SRC_FLOW ) {
+ return true;
+ }
+
+ set_error_handler( new Flow\RecoverableErrorHandler, -1 );
+ try {
+ /** @var Flow\Formatter\RecentChangesQuery $query */
+ $query = Container::get( 'query.recentchanges' );
+
+ $row = $query->getResult( $changesList, $rc,
$changesList->isWatchlist() );
+ if ( $row === false ) {
+ restore_error_handler();
+ return false;
+ }
+
+ /** @var Flow\Formatter\RecentChanges $formatter */
+ $formatter = Container::get( 'formatter.recentchanges'
);
+ $links = $formatter->getLogTextLinks( $row,
$changesList, $block, $links );
+ } catch ( Exception $e ) {
+ wfDebugLog( 'Flow', __METHOD__ . ': Exception
formatting rc logtext ' . $rc->getAttribute( 'rc_id' ) . ' ' . $e );
+ MWExceptionHandler::logException( $e );
+ restore_error_handler();
+ return false;
+ }
+ restore_error_handler();
+
+ return true;
+ }
+
public static function onSpecialCheckUserGetLinksFromRow( CheckUser
$checkUser, $row, &$links ) {
if ( !$row->cuc_type == RC_FLOW ) {
return true;
diff --git a/includes/Formatter/RecentChanges.php
b/includes/Formatter/RecentChanges.php
index 04e0d70..4cb94d2 100644
--- a/includes/Formatter/RecentChanges.php
+++ b/includes/Formatter/RecentChanges.php
@@ -157,4 +157,38 @@
// now pass it on to parent with the new, updated, link ;)
return parent::getTitleLink( $data, $row, $ctx );
}
+
+ /**
+ * @param RecentChangesRow $row
+ * @param IContextSource $ctx
+ * @param array $block
+ * @param array $links
+ * @return array
+ * @throws FlowException
+ * @throws \Flow\Exception\InvalidInputException
+ */
+ public function getLogTextLinks( RecentChangesRow $row, IContextSource
$ctx, array $block, array $links = array() ) {
+ $old = unserialize( $block[count( $block ) -
1]->mAttribs['rc_params'] );
+ $oldId = $old ? UUID::create(
$old['flow-workflow-change']['revision'] ) : $row->revision->getRevisionId();
+
+ $data = $this->serializer->formatApi( $row, $ctx );
+ if ( !$data ) {
+ throw new FlowException( 'Could not format data for row
' . $row->revision->getRevisionId()->getAlphadecimal() );
+ }
+
+ // add highlight details to anchor
+ /** @var Anchor $anchor */
+ $anchor = clone $data['links']['topic'];
+ $anchor->query['fromnotif'] = '1';
+ $anchor->fragment = '#flow-post-' . $oldId->getAlphadecimal();
+
+ $changes = count($block);
+ // link text: "n changes"
+ $text = $ctx->msg( 'nchanges' )->numParams( $changes
)->escaped();
+
+ // override total changes link
+ $links['total-changes'] = $anchor->toHtml( $text );
+
+ return $links;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/193094
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I127b64d1b97cb981a8a8c82c836cd97db62cc918
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits