Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / includes / specials / SpecialDeletedContributions.php
index e4672f8..40d8962 100644 (file)
@@ -21,6 +21,7 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\MediaWikiServices;
 
 /**
@@ -45,8 +46,7 @@ class DeletedContributionsPage extends SpecialPage {
                $this->setHeaders();
                $this->outputHeader();
                $this->checkPermissions();
-
-               $user = $this->getUser();
+               $this->addHelpLink( 'Help:User contributions' );
 
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'deletedcontributions-title' ) );
@@ -101,8 +101,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,23 +145,27 @@ 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 );
 
                        // Show a note if the user is blocked and display the last block log entry.
-                       $block = Block::newFromTarget( $userObj, $userObj );
-                       if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
-                               if ( $block->getType() == Block::TYPE_RANGE ) {
-                                       $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
+                       $block = DatabaseBlock::newFromTarget( $userObj, $userObj );
+                       if ( !is_null( $block ) && $block->getType() != DatabaseBlock::TYPE_AUTO ) {
+                               if ( $block->getType() == DatabaseBlock::TYPE_RANGE ) {
+                                       $nt = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                               getCanonicalName( NS_USER ) . ':' . $block->getTarget();
                                }
 
                                // LogEventsList::showLogExtract() wants the first parameter by ref