Prevent PHP notice on SpecialDeletedContributions
authorMatěj Suchánek <matejsuchanek97@gmail.com>
Thu, 14 Feb 2019 09:47:54 +0000 (10:47 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 15 Feb 2019 18:45:09 +0000 (18:45 +0000)
Bug: T208544
Change-Id: Ie8d5c3d7257134857713853eec8e0eb42890366a

includes/GlobalFunctions.php
includes/specials/SpecialDeletedContributions.php

index bd98932..51fe167 100644 (file)
@@ -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 ) {
index e4672f8..6022ff4 100644 (file)
@@ -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 );