$this->opts['newOnly'] = $request->getBool( 'newOnly' );
$this->opts['hideMinor'] = $request->getBool( 'hideMinor' );
- $nt = Title::makeTitleSafe( NS_USER, $target );
- if ( !$nt ) {
- $out->addHTML( $this->getForm() );
-
- return;
- }
- $userObj = User::newFromName( $nt->getText(), false );
- if ( !$userObj ) {
- $out->addHTML( $this->getForm() );
+ $id = 0;
+ if ( $this->opts['contribs'] === 'newbie' ) {
+ $userObj = User::newFromName( $target ); // hysterical raisins
+ $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
+ $out->setHTMLTitle( $this->msg(
+ 'pagetitle',
+ $this->msg( 'sp-contributions-newbies-title' )->plain()
+ )->inContentLanguage() );
+ } elseif ( ExternalUserNames::isExternal( $target ) ) {
+ $userObj = User::newFromName( $target, false );
+ if ( !$userObj ) {
+ $out->addHTML( $this->getForm() );
+ return;
+ }
- return;
- }
- $id = $userObj->getId();
+ $out->addSubtitle( $this->contributionsSub( $userObj ) );
+ $out->setHTMLTitle( $this->msg(
+ 'pagetitle',
+ $this->msg( 'contributions-title', $target )->plain()
+ )->inContentLanguage() );
+ } else {
+ $nt = Title::makeTitleSafe( NS_USER, $target );
+ if ( !$nt ) {
+ $out->addHTML( $this->getForm() );
+ return;
+ }
+ $userObj = User::newFromName( $nt->getText(), false );
+ if ( !$userObj ) {
+ $out->addHTML( $this->getForm() );
+ return;
+ }
+ $id = $userObj->getId();
- if ( $this->opts['contribs'] != 'newbie' ) {
$target = $nt->getText();
$out->addSubtitle( $this->contributionsSub( $userObj ) );
$out->setHTMLTitle( $this->msg(
if ( !IP::isValidRange( $target ) ) {
$this->getSkin()->setRelevantUser( $userObj );
}
- } else {
- $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
- $out->setHTMLTitle( $this->msg(
- 'pagetitle',
- $this->msg( 'sp-contributions-newbies-title' )->plain()
- )->inContentLanguage() );
}
$ns = $request->getVal( 'namespace', null );
} elseif ( !$pager->getNumRows() ) {
$out->addWikiMsg( 'nocontribs', $target );
} else {
- # Show a message about replica DB lag, if applicable
- $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
- $lag = $lb->safeGetLag( $pager->getDatabase() );
- if ( $lag > 0 ) {
- $out->showLagWarning( $lag );
- }
-
- $output = $pager->getBody();
- if ( !$this->including() ) {
- $output = '<p>' . $pager->getNavigationBar() . '</p>' .
- $output .
- '<p>' . $pager->getNavigationBar() . '</p>';
+ // @todo We just want a wiki ID here, not a "DB domain", but
+ // current status of MediaWiki conflates the two. See T235955.
+ $poolKey = WikiMap::getCurrentWikiDbDomain() . ':SpecialContributions:';
+ if ( $this->getUser()->isAnon() ) {
+ $poolKey .= 'a:' . $this->getUser()->getName();
+ } else {
+ $poolKey .= 'u:' . $this->getUser()->getId();
}
- $out->addHTML( $output );
+ $work = new PoolCounterWorkViaCallback( 'SpecialContributions', $poolKey, [
+ 'doWork' => function () use ( $pager, $out ) {
+ # Show a message about replica DB lag, if applicable
+ $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
+ $lag = $lb->safeGetLag( $pager->getDatabase() );
+ if ( $lag > 0 ) {
+ $out->showLagWarning( $lag );
+ }
+
+ $output = $pager->getBody();
+ if ( !$this->including() ) {
+ $output = '<p>' . $pager->getNavigationBar() . '</p>' .
+ $output .
+ '<p>' . $pager->getNavigationBar() . '</p>';
+ }
+ $out->addHTML( $output );
+ },
+ 'error' => function () use ( $out ) {
+ $msg = $this->getUser()->isAnon()
+ ? 'sp-contributions-concurrency-ip'
+ : 'sp-contributions-concurrency-user';
+ $out->wrapWikiMsg( "<div class='errorbox'>\n$1\n</div>", $msg );
+ }
+ ] );
+ $work->execute();
}
$out->preventClickjacking( $pager->getPreventClickjacking() );