X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialContributions.php;h=62b34ad38b2fa39f23cd341bfd229233e070d560;hb=dac90fa456287c26aedb422d9aa6b743dcbc1a4a;hp=a0482045e67e039e065781a1afe0ed04d26494ec;hpb=dd44f2dcedaad4743d304b33fba7a405d9f85b57;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index a0482045e6..62b34ad38b 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -44,10 +44,7 @@ class SpecialContributions extends SpecialPage { $this->opts = array(); $request = $this->getRequest(); - if ( $par == 'newbies' ) { - $target = 'newbies'; - $this->opts['contribs'] = 'newbie'; - } elseif ( $par !== null ) { + if ( $par !== null ) { $target = $par; } else { $target = $request->getVal( 'target' ); @@ -57,6 +54,9 @@ class SpecialContributions extends SpecialPage { if ( $request->getVal( 'contribs' ) == 'newbie' ) { $target = 'newbies'; $this->opts['contribs'] = 'newbie'; + } elseif ( $par === 'newbies' ) { // b/c for WMF + $target = 'newbies'; + $this->opts['contribs'] = 'newbie'; } else { $this->opts['contribs'] = 'user'; } @@ -74,12 +74,16 @@ class SpecialContributions extends SpecialPage { $this->opts['target'] = $target; $this->opts['topOnly'] = $request->getBool( 'topOnly' ); - $userObj = User::newFromName( $target, false ); + $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; } - $nt = $userObj->getUserPage(); $id = $userObj->getID(); if ( $this->opts['contribs'] != 'newbie' ) { @@ -103,7 +107,6 @@ class SpecialContributions extends SpecialPage { $this->opts['nsInvert'] = (bool) $request->getVal( 'nsInvert' ); $this->opts['tagfilter'] = (string) $request->getVal( 'tagfilter' ); - $this->opts['tagfilterdropdown'] = (string) $request->getVal( 'tagfilterdropdown' ); // Allows reverts to have the bot flag in recent changes. It is just here to // be passed in the form at the top of the page @@ -139,9 +142,6 @@ class SpecialContributions extends SpecialPage { if ( $this->opts['tagfilter'] !== '' ) { $apiParams['tagfilter'] = $this->opts['tagfilter']; } - if ( $this->opts['tagfilterdropdown'] !== '' && $this->opts['tagfilterdropdown'] !== 'other' ) { - $apiParams['tagfilter'] = $this->opts['tagfilterdropdown']; - } if ( $this->opts['namespace'] !== '' ) { $apiParams['namespace'] = $this->opts['namespace']; } @@ -192,18 +192,20 @@ class SpecialContributions extends SpecialPage { } $out->preventClickjacking( $pager->getPreventClickjacking() ); + # Show the appropriate "footer" message - WHOIS tools, etc. - if ( $this->opts['contribs'] != 'newbie' ) { + if ( $this->opts['contribs'] == 'newbie' ) { + $message = 'sp-contributions-footer-newbies'; + } elseif( IP::isIPAddress( $target ) ) { + $message = 'sp-contributions-footer-anon'; + } elseif( $userObj->isAnon() ) { + // No message for non-existing users + $message = ''; + } else { $message = 'sp-contributions-footer'; - if ( IP::isIPAddress( $target ) ) { - $message = 'sp-contributions-footer-anon'; - } else { - if ( $userObj->isAnon() ) { - // No message for non-existing users - return; - } - } + } + if( $message ) { if ( !$this->msg( $message, $target )->isDisabled() ) { $out->wrapWikiMsg( "", @@ -227,12 +229,15 @@ class SpecialContributions extends SpecialPage { } $nt = $userObj->getUserPage(); $talk = $userObj->getTalkPage(); + $links = ''; if ( $talk ) { $tools = $this->getUserLinks( $nt, $talk, $userObj ); $links = $this->getLanguage()->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. - if ( $userObj->isBlocked() ) { + // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs, + // and also this will display a totally irrelevant log entry as a current block. + if ( $userObj->isBlocked() && $userObj->getBlock()->getType() != Block::TYPE_AUTO ) { $out = $this->getOutput(); // showLogExtract() wants first parameter by reference LogEventsList::showLogExtract( $out, @@ -258,9 +263,11 @@ class SpecialContributions extends SpecialPage { // languages that want to put the "for" bit right after $user but before // $links. If 'contribsub' is around, use it for reverse compatibility, // otherwise use 'contribsub2'. + // @todo Should this be removed at some point? $oldMsg = $this->msg( 'contribsub' ); if ( $oldMsg->exists() ) { - return $oldMsg->rawParams( "$user ($links)" ); + $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped(); + return $oldMsg->rawParams( "$user $linksWithParentheses" ); } else { return $this->msg( 'contribsub2' )->rawParams( $user, $links ); } @@ -331,7 +338,7 @@ class SpecialContributions extends SpecialPage { # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext( $this->getContext() ); - if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) { + if ( $userrightsPage->userCanChangeRights( $target ) ) { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Userrights', $username ), $this->msg( 'sp-contributions-userrights' )->escaped() @@ -403,11 +410,7 @@ class SpecialContributions extends SpecialPage { $form .= "\t" . Html::hidden( $name, $value ) . "\n"; } - $tagFilter = ChangeTags::buildTagFilterWithDropdown( - 'tag-filter-dropdown-list', - $this->opts['tagfilter'], - $this->opts['tagfilterdropdown'] - ); + $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] ); if ( $tagFilter ) { $filterSelection = @@ -453,7 +456,15 @@ class SpecialContributions extends SpecialPage { ) ) . Xml::tags( 'td', null, - Xml::namespaceSelector( $this->opts['namespace'], '' ) . ' ' . + Html::namespaceSelector( array( + 'selected' => $this->opts['namespace'], + 'all' => '', + ), array( + 'name' => 'namespace', + 'id' => 'namespace', + 'class' => 'namespaceselector', + ) ) . + ' ' . Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ), Xml::checkLabel( $this->msg( 'invert' )->text(), @@ -519,9 +530,9 @@ class SpecialContributions extends SpecialPage { $filterSelection . Xml::closeElement( 'tr' ) . Xml::openElement( 'tr' ) . - $extraOptions . - Xml::closeElement( 'tr' ) . - Xml::openElement( 'tr' ) . + $extraOptions . + Xml::closeElement( 'tr' ) . + Xml::openElement( 'tr' ) . $dateSelectionAndSubmit . Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' ); @@ -546,6 +557,11 @@ class ContribsPager extends ReverseChronologicalPager { var $namespace = '', $mDb; var $preventClickjacking = false; + /** + * @var array + */ + protected $mParentLens; + function __construct( IContextSource $context, array $options ) { parent::__construct( $context ); @@ -636,12 +652,13 @@ class ContribsPager extends ReverseChronologicalPager { # @todo FIXME: Other groups may have 'bot' rights $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" ); } else { - if ( IP::isIPAddress( $this->target ) ) { + $uid = User::idFromName( $this->target ); + if ( $uid ) { + $condition['rev_user'] = $uid; + $index = 'user_timestamp'; + } else { $condition['rev_user_text'] = $this->target; $index = 'usertext_timestamp'; - } else { - $condition['rev_user'] = User::idFromName( $this->target ); - $index = 'user_timestamp'; } } if ( $this->deletedOnly ) { @@ -685,27 +702,32 @@ class ContribsPager extends ReverseChronologicalPager { $this->mResult->rewind(); $revIds = array(); foreach ( $this->mResult as $row ) { - $revIds[] = $row->rev_parent_id; + if( $row->rev_parent_id ) { + $revIds[] = $row->rev_parent_id; + } } $this->mParentLens = $this->getParentLengths( $revIds ); $this->mResult->rewind(); // reset - if ( $this->contribs === 'newbie' ) { // multiple users - # Do a link batch query - $this->mResult->seek( 0 ); - $batch = new LinkBatch(); - # Give some pointers to make (last) links - foreach ( $this->mResult as $row ) { - $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) ); - $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) ); + # Do a link batch query + $this->mResult->seek( 0 ); + $batch = new LinkBatch(); + # Give some pointers to make (last) links + foreach ( $this->mResult as $row ) { + if ( $this->contribs === 'newbie' ) { // multiple users + $batch->add( NS_USER, $row->user_name ); + $batch->add( NS_USER_TALK, $row->user_name ); } - $batch->execute(); - $this->mResult->seek( 0 ); + $batch->add( $row->page_namespace, $row->page_title ); } + $batch->execute(); + $this->mResult->seek( 0 ); } /** * Do a batched query to get the parent revision lengths + * @param $revIds array + * @return array */ private function getParentLengths( array $revIds ) { $revLens = array(); @@ -747,6 +769,8 @@ class ContribsPager extends ReverseChronologicalPager { * was not written by the target user. * * @todo This would probably look a lot nicer in a table. + * @param $row + * @return string */ function formatRow( $row ) { wfProfileIn( __METHOD__ ); @@ -795,11 +819,15 @@ class ContribsPager extends ReverseChronologicalPager { array( 'action' => 'history' ) ); - if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) { - $chardiff = ' . . ' . ChangesList::showCharacterDifference( - $this->mParentLens[$row->rev_parent_id], $row->rev_len ) . ' . . '; + if ( $row->rev_parent_id === null ) { + // For some reason rev_parent_id isn't populated for this row. + // Its rumoured this is true on wikipedia for some revisions (bug 34922). + // Next best thing is to have the total number of bytes. + $chardiff = ' . . ' . Linker::formatRevisionSize( $row->rev_len ) . ' . . '; } else { - $chardiff = ' '; + $parentLen = isset( $this->mParentLens[$row->rev_parent_id] ) ? $this->mParentLens[$row->rev_parent_id] : 0; + $chardiff = ' . . ' . ChangesList::showCharacterDifference( + $parentLen, $row->rev_len ) . ' . . '; } $lang = $this->getLanguage(); @@ -846,7 +874,7 @@ class ContribsPager extends ReverseChronologicalPager { $del .= ' '; } - $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')'; + $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages['pipe-separator'] . $histlink )->escaped(); $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}"; # Denote if username is redacted for this edit @@ -879,6 +907,7 @@ class ContribsPager extends ReverseChronologicalPager { /** * Overwrite Pager function and return a helpful comment + * @return string */ function getSqlComment() { if ( $this->namespace || $this->deletedOnly ) { @@ -892,6 +921,9 @@ class ContribsPager extends ReverseChronologicalPager { $this->preventClickjacking = true; } + /** + * @return bool + */ public function getPreventClickjacking() { return $this->preventClickjacking; }