From 2c8db66fa496c6c9935873d604d99170201a8ab8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Thu, 14 Feb 2019 10:47:54 +0100 Subject: [PATCH] Prevent PHP notice on SpecialDeletedContributions Bug: T208544 Change-Id: Ie8d5c3d7257134857713853eec8e0eb42890366a --- includes/GlobalFunctions.php | 2 +- includes/specials/SpecialDeletedContributions.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index bd989328f4..51fe1671d4 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -225,7 +225,7 @@ function wfMergeErrorArrays( ...$args ) { * * @param array $array The array. * @param array $insert The array to insert. - * @param mixed $after The key to insert after + * @param mixed $after The key to insert after. Callers need to make sure the key is set. * @return array */ function wfArrayInsertAfter( array $array, array $insert, $after ) { diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index e4672f8a01..6022ff4816 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -146,15 +146,18 @@ class DeletedContributionsPage extends SpecialPage { if ( $talk ) { $tools = SpecialContributions::getUserLinks( $this, $userObj ); - # Link to contributions - $insert['contribs'] = $linkRenderer->makeKnownLink( + $contributionsLink = $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ), $this->msg( 'sp-deletedcontributions-contribs' )->text() ); - - // Swap out the deletedcontribs link for our contribs one - $tools = wfArrayInsertAfter( $tools, $insert, 'deletedcontribs' ); - unset( $tools['deletedcontribs'] ); + if ( isset( $tools['deletedcontribs'] ) ) { + // Swap out the deletedcontribs link for our contribs one + $tools = wfArrayInsertAfter( + $tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' ); + unset( $tools['deletedcontribs'] ); + } else { + $tools['contribs'] = $contributionsLink; + } $links = $this->getLanguage()->pipeList( $tools ); -- 2.20.1