specials: Avoid the use of global variables in Special:Version
[lhc/web/wiklou.git] / includes / specials / SpecialDeletedContributions.php
index e4672f8..65cf79e 100644 (file)
@@ -21,8 +21,6 @@
  * @ingroup SpecialPage
  */
 
-use MediaWiki\MediaWikiServices;
-
 /**
  * Implements Special:DeletedContributions to display archived revisions
  * @ingroup SpecialPage
@@ -46,8 +44,6 @@ class DeletedContributionsPage extends SpecialPage {
                $this->outputHeader();
                $this->checkPermissions();
 
-               $user = $this->getUser();
-
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'deletedcontributions-title' ) );
 
@@ -101,8 +97,7 @@ class DeletedContributionsPage extends SpecialPage {
                }
 
                # Show a message about replica DB lag, if applicable
-               $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
-               $lag = $lb->safeGetLag( $pager->getDatabase() );
+               $lag = $pager->getDatabase()->getSessionLagStatus()['lag'];
                if ( $lag > 0 ) {
                        $out->showLagWarning( $lag );
                }
@@ -146,15 +141,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 );