From: Matěj Suchánek Date: Thu, 14 Feb 2019 09:47:54 +0000 (+0100) Subject: Prevent PHP notice on SpecialDeletedContributions X-Git-Tag: 1.34.0-rc.0~2813 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=2c8db66fa496c6c9935873d604d99170201a8ab8 Prevent PHP notice on SpecialDeletedContributions Bug: T208544 Change-Id: Ie8d5c3d7257134857713853eec8e0eb42890366a --- 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 );