*
* @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 ) {
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 );