From a73d63d1a4a3110a4d8d542f278b5c2626950a45 Mon Sep 17 00:00:00 2001 From: Stephane Bisson Date: Tue, 23 Feb 2016 12:46:36 -0500 Subject: [PATCH] Echo API returns absolute URLs in notification links Some notifications return relative urls in their primary or secondary links. This change makes those urls absolute so they point to the right wiki when viewed from another wiki (cross-wiki notifications). Bug: T125738 Bug: T127697 Change-Id: Ib65337430eb2484f9491668a9998deef70589fb1 --- includes/formatters/EchoModelFormatter.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/formatters/EchoModelFormatter.php b/includes/formatters/EchoModelFormatter.php index 33ec11ae4..2ca6bcd9d 100644 --- a/includes/formatters/EchoModelFormatter.php +++ b/includes/formatters/EchoModelFormatter.php @@ -12,6 +12,15 @@ class EchoModelFormatter extends EchoEventFormatter { protected function formatModel( EchoEventPresentationModel $model ) { $data = $model->jsonSerialize(); $data['iconUrl'] = EchoNotificationFormatter::getIconUrl( $model->getIconType(), $this->language->getDir() ); + + if ( isset( $data['links']['primary']['url'] ) ) { + $data['links']['primary']['url'] = wfExpandUrl( $data['links']['primary']['url'] ); + } + + foreach ( $data['links']['secondary'] as &$link ) { + $link['url'] = wfExpandUrl( $link['url'] ); + } + return $data; } }