jenkins-bot has submitted this change and it was merged.
Change subject: Reduced indentation levels, broke long lines
......................................................................
Reduced indentation levels, broke long lines
Also removed some unneeded else blocks to ensure more consistent return values.
Change-Id: Icf1d6fecfbd512fadad61442c968f0ef1ba30a88
---
M includes/specials/SpecialContributions.php
1 file changed, 211 insertions(+), 137 deletions(-)
Approvals:
Alex Monk: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specials/SpecialContributions.php
b/includes/specials/SpecialContributions.php
index 75983e8..e985811 100644
--- a/includes/specials/SpecialContributions.php
+++ b/includes/specials/SpecialContributions.php
@@ -28,7 +28,6 @@
*/
class SpecialContributions extends SpecialPage {
-
protected $opts;
public function __construct() {
@@ -89,11 +88,17 @@
if ( $this->opts['contribs'] != 'newbie' ) {
$target = $nt->getText();
$out->addSubtitle( $this->contributionsSub( $userObj )
);
- $out->setHTMLTitle( $this->msg( 'pagetitle',
$this->msg( 'contributions-title', $target )->plain() ) );
+ $out->setHTMLTitle( $this->msg(
+ 'pagetitle',
+ $this->msg( 'contributions-title', $target
)->plain()
+ ) );
$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() ) );
+ $out->setHTMLTitle( $this->msg(
+ 'pagetitle',
+ $this->msg( 'sp-contributions-newbies-title'
)->plain()
+ ) );
}
if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null
&& $ns !== '' ) {
@@ -103,10 +108,8 @@
}
$this->opts['associated'] = $request->getBool( 'associated' );
-
- $this->opts['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
-
- $this->opts['tagfilter'] = (string) $request->getVal(
'tagfilter' );
+ $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' );
+ $this->opts['tagfilter'] = (string)$request->getVal(
'tagfilter' );
// 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
@@ -162,7 +165,6 @@
$this->addFeedLinks( array( 'action' => 'feedcontributions',
'user' => $target ) );
if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array(
$id ) ) ) {
-
$out->addHTML( $this->getForm() );
$pager = new ContribsPager( $this->getContext(), array(
@@ -176,18 +178,20 @@
'nsInvert' => $this->opts['nsInvert'],
'associated' => $this->opts['associated'],
) );
+
if ( !$pager->getNumRows() ) {
$out->addWikiMsg( 'nocontribs', $target );
} else {
# Show a message about slave lag, if applicable
$lag = wfGetLB()->safeGetLag(
$pager->getDatabase() );
- if ( $lag > 0 )
+ if ( $lag > 0 ) {
$out->showLagWarning( $lag );
+ }
$out->addHTML(
'<p>' . $pager->getNavigationBar() .
'</p>' .
- $pager->getBody() .
- '<p>' . $pager->getNavigationBar() .
'</p>'
+ $pager->getBody() .
+ '<p>' .
$pager->getNavigationBar() . '</p>'
);
}
$out->preventClickjacking(
$pager->getPreventClickjacking() );
@@ -195,16 +199,16 @@
# Show the appropriate "footer" message - WHOIS tools,
etc.
if ( $this->opts['contribs'] == 'newbie' ) {
$message = 'sp-contributions-footer-newbies';
- } elseif( IP::isIPAddress( $target ) ) {
+ } elseif ( IP::isIPAddress( $target ) ) {
$message = 'sp-contributions-footer-anon';
- } elseif( $userObj->isAnon() ) {
+ } elseif ( $userObj->isAnon() ) {
// No message for non-existing users
$message = '';
} else {
$message = 'sp-contributions-footer';
}
- if( $message ) {
+ if ( $message ) {
if ( !$this->msg( $message, $target
)->isDisabled() ) {
$out->wrapWikiMsg(
"<div
class='mw-contributions-footer'>\n$1\n</div>",
@@ -267,9 +271,9 @@
if ( $oldMsg->exists() ) {
$linksWithParentheses = $this->msg( 'parentheses'
)->rawParams( $links )->escaped();
return $oldMsg->rawParams( "$user
$linksWithParentheses" );
- } else {
- return $this->msg( 'contribsub2' )->rawParams( $user,
$links );
}
+
+ return $this->msg( 'contribsub2' )->rawParams( $user, $links );
}
/**
@@ -309,9 +313,7 @@
SpecialPage::getTitleFor( 'Log', 'block' ),
$this->msg( 'sp-contributions-blocklog'
)->escaped(),
array(),
- array(
- 'page' => $userpage->getPrefixedText()
- )
+ array( 'page' => $userpage->getPrefixedText() )
);
}
# Uploads
@@ -398,10 +400,28 @@
$this->opts['topOnly'] = false;
}
- $form = Html::openElement( 'form', array( 'method' => 'get',
'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
+ $form = Html::openElement(
+ 'form',
+ array(
+ 'method' => 'get',
+ 'action' => $wgScript,
+ 'class' => 'mw-contributions-form'
+ )
+ );
# Add hidden params for tracking except for parameters in
$skipParameters
- $skipParameters = array( 'namespace', 'nsInvert',
'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
+ $skipParameters = array(
+ 'namespace',
+ 'nsInvert',
+ 'deletedOnly',
+ 'target',
+ 'contribs',
+ 'year',
+ 'month',
+ 'topOnly',
+ 'associated'
+ );
+
foreach ( $this->opts as $name => $value ) {
if ( in_array( $name, $skipParameters ) ) {
continue;
@@ -412,80 +432,102 @@
$tagFilter = ChangeTags::buildTagFilterSelector(
$this->opts['tagfilter'] );
if ( $tagFilter ) {
- $filterSelection =
- Html::rawElement( 'td', array( 'class' =>
'mw-label' ), array_shift( $tagFilter ) ) .
- Html::rawElement( 'td', array( 'class' =>
'mw-input' ), implode( ' ', $tagFilter ) );
+ $filterSelection = Html::rawElement(
+ 'td',
+ array( 'class' => 'mw-label' ),
+ array_shift( $tagFilter )
+ );
+ $filterSelection .= Html::rawElement(
+ 'td',
+ array( 'class' => 'mw-input' ),
+ implode( ' ', $tagFilter )
+ );
} else {
$filterSelection = Html::rawElement( 'td', array(
'colspan' => 2 ), '' );
}
- $targetSelection = Html::rawElement( 'td', array( 'colspan' =>
2 ),
- Xml::radioLabel(
- $this->msg( 'sp-contributions-newbies'
)->text(),
- 'contribs',
- 'newbie',
- 'newbie',
- $this->opts['contribs'] == 'newbie',
- array( 'class' => 'mw-input' )
- ) . '<br />' .
- Xml::radioLabel(
- $this->msg( 'sp-contributions-username'
)->text(),
- 'contribs',
- 'user',
- 'user',
- $this->opts['contribs'] == 'user',
- array( 'class' => 'mw-input' )
- ) . ' ' .
- Html::input(
- 'target',
- $this->opts['target'],
- 'text',
- array( 'size' => '40', 'required' => '',
'class' => 'mw-input' ) +
- ( $this->opts['target'] ? array() :
array( 'autofocus' )
+ $labelNewbies = Xml::radioLabel(
+ $this->msg( 'sp-contributions-newbies' )->text(),
+ 'contribs',
+ 'newbie',
+ 'newbie',
+ $this->opts['contribs'] == 'newbie',
+ array( 'class' => 'mw-input' )
+ );
+ $labelUsername = Xml::radioLabel(
+ $this->msg( 'sp-contributions-username' )->text(),
+ 'contribs',
+ 'user',
+ 'user',
+ $this->opts['contribs'] == 'user',
+ array( 'class' => 'mw-input' )
+ );
+ $input = Html::input(
+ 'target',
+ $this->opts['target'],
+ 'text',
+ array( 'size' => '40', 'required' => '', 'class' =>
'mw-input' ) +
+ ( $this->opts['target'] ? array() : array(
'autofocus' )
)
- ) . ' '
+ );
+ $targetSelection = Html::rawElement(
+ 'td',
+ array( 'colspan' => 2 ),
+ $labelNewbies . '<br />' . $labelUsername . ' ' .
$input . ' '
);
- $namespaceSelection =
- Xml::tags( 'td', array( 'class' => 'mw-label' ),
- Xml::label(
- $this->msg( 'namespace' )->text(),
- 'namespace',
- ''
- )
- ) .
- Html::rawElement( 'td', null,
- Html::namespaceSelector( array(
- 'selected' => $this->opts['namespace'],
- 'all' => '',
- ), array(
- 'name' => 'namespace',
- 'id' => 'namespace',
+ $namespaceSelection = Xml::tags(
+ 'td',
+ array( 'class' => 'mw-label' ),
+ Xml::label(
+ $this->msg( 'namespace' )->text(),
+ 'namespace',
+ ''
+ )
+ );
+ $namespaceSelection .= Html::rawElement(
+ 'td',
+ null,
+ 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(),
- 'nsInvert',
- 'nsInvert',
- $this->opts['nsInvert'],
- array( 'title' => $this->msg(
'tooltip-invert' )->text(), 'class' => 'mw-input' )
- ) . ' '
- ) .
- Html::rawElement( 'span', array( 'style' =>
'white-space: nowrap' ),
- Xml::checkLabel(
- $this->msg(
'namespace_association' )->text(),
- 'associated',
- 'associated',
- $this->opts['associated'],
- array( 'title' => $this->msg(
'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
- ) . ' '
)
- );
+ ) . ' ' .
+ Html::rawElement(
+ 'span',
+ array( 'style' => 'white-space: nowrap' ),
+ Xml::checkLabel(
+ $this->msg( 'invert' )->text(),
+ 'nsInvert',
+ 'nsInvert',
+ $this->opts['nsInvert'],
+ array(
+ 'title' => $this->msg(
'tooltip-invert' )->text(),
+ 'class' => 'mw-input'
+ )
+ ) . ' '
+ ) .
+ Html::rawElement( 'span', array( 'style' =>
'white-space: nowrap' ),
+ Xml::checkLabel(
+ $this->msg( 'namespace_association'
)->text(),
+ 'associated',
+ 'associated',
+ $this->opts['associated'],
+ array(
+ 'title' => $this->msg(
'tooltip-namespace_association' )->text(),
+ 'class' => 'mw-input'
+ )
+ ) . ' '
+ )
+ );
if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
- $deletedOnlyCheck = Html::rawElement( 'span', array(
'style' => 'white-space: nowrap' ),
+ $deletedOnlyCheck = Html::rawElement(
+ 'span',
+ array( 'style' => 'white-space: nowrap' ),
Xml::checkLabel(
$this->msg( 'history-show-deleted'
)->text(),
'deletedOnly',
@@ -498,17 +540,21 @@
$deletedOnlyCheck = '';
}
- $extraOptions = Html::rawElement( 'td', array( 'colspan' => 2 ),
- $deletedOnlyCheck .
- Html::rawElement( 'span', array( 'style' =>
'white-space: nowrap' ),
- Xml::checkLabel(
- $this->msg( 'sp-contributions-toponly'
)->text(),
- 'topOnly',
- 'mw-show-top-only',
- $this->opts['topOnly'],
- array( 'class' => 'mw-input' )
- )
+ $checkLabelTopOnly = Html::rawElement(
+ 'span',
+ array( 'style' => 'white-space: nowrap' ),
+ Xml::checkLabel(
+ $this->msg( 'sp-contributions-toponly'
)->text(),
+ 'topOnly',
+ 'mw-show-top-only',
+ $this->opts['topOnly'],
+ array( 'class' => 'mw-input' )
)
+ );
+ $extraOptions = Html::rawElement(
+ 'td',
+ array( 'colspan' => 2 ),
+ $deletedOnlyCheck . $checkLabelTopOnly
);
$dateSelectionAndSubmit = Xml::tags( 'td', array( 'colspan' =>
2 ),
@@ -516,28 +562,28 @@
$this->opts['year'],
$this->opts['month']
) . ' ' .
- Xml::submitButton(
- $this->msg( 'sp-contributions-submit' )->text(),
- array( 'class' => 'mw-submit' )
- )
+ Xml::submitButton(
+ $this->msg( 'sp-contributions-submit'
)->text(),
+ array( 'class' => 'mw-submit' )
+ )
);
- $form .=
- Xml::fieldset( $this->msg( 'sp-contributions-search'
)->text() ) .
- Html::rawElement( 'table', array( 'class' =>
'mw-contributions-table' ), "\n" .
- Html::rawElement( 'tr', array(),
$targetSelection ) . "\n" .
- Html::rawElement( 'tr', array(),
$namespaceSelection ) . "\n" .
- Html::rawElement( 'tr', array(),
$filterSelection ) . "\n" .
- Html::rawElement( 'tr', array(), $extraOptions
) . "\n" .
- Html::rawElement( 'tr', array(),
$dateSelectionAndSubmit ) . "\n"
- );
+ $form .= Xml::fieldset( $this->msg( 'sp-contributions-search'
)->text() );
+ $form .= Html::rawElement( 'table', array( 'class' =>
'mw-contributions-table' ), "\n" .
+ Html::rawElement( 'tr', array(), $targetSelection ) .
"\n" .
+ Html::rawElement( 'tr', array(), $namespaceSelection )
. "\n" .
+ Html::rawElement( 'tr', array(), $filterSelection ) .
"\n" .
+ Html::rawElement( 'tr', array(), $extraOptions ) . "\n"
.
+ Html::rawElement( 'tr', array(),
$dateSelectionAndSubmit ) . "\n"
+ );
$explain = $this->msg( 'sp-contributions-explain' );
if ( !$explain->isBlank() ) {
$form .= "<p
id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
}
- $form .= Xml::closeElement( 'fieldset' ) .
- Xml::closeElement( 'form' );
+
+ $form .= Xml::closeElement( 'fieldset' ) . Xml::closeElement(
'form' );
+
return $form;
}
@@ -564,7 +610,15 @@
function __construct( IContextSource $context, array $options ) {
parent::__construct( $context );
- $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink',
'diff', 'hist', 'rev-delundel', 'pipe-separator' );
+ $msgs = array(
+ 'diff',
+ 'hist',
+ 'newarticle',
+ 'pipe-separator',
+ 'rev-delundel',
+ 'rollbacklink',
+ 'uctop'
+ );
foreach ( $msgs as $msg ) {
$this->messages[$msg] = $this->msg( $msg )->escaped();
@@ -603,7 +657,11 @@
* @return ResultWrapper
*/
function reallyDoQuery( $offset, $limit, $descending ) {
- list( $tables, $fields, $conds, $fname, $options, $join_conds )
= $this->buildQueryInfo( $offset, $limit, $descending );
+ list( $tables, $fields, $conds, $fname, $options, $join_conds )
= $this->buildQueryInfo(
+ $offset,
+ $limit,
+ $descending
+ );
$pager = $this;
/*
@@ -673,15 +731,15 @@
$join_cond['user'] = Revision::userJoinCond();
$queryInfo = array(
- 'tables' => $tables,
- 'fields' => array_merge(
+ 'tables' => $tables,
+ 'fields' => array_merge(
Revision::selectFields(),
Revision::selectUserFields(),
array( 'page_namespace', 'page_title',
'page_is_new',
'page_latest', 'page_is_redirect',
'page_len' )
),
- 'conds' => $conds,
- 'options' => array( 'USE INDEX' => array( 'revision'
=> $index ) ),
+ 'conds' => $conds,
+ 'options' => array( 'USE INDEX' => array( 'revision' =>
$index ) ),
'join_conds' => $join_cond
);
@@ -709,7 +767,7 @@
# ignore local groups with the bot right
# @todo FIXME: Global groups may have 'bot' rights
$groupsWithBotPermission =
User::getGroupsWithPermission( 'bot' );
- if( count( $groupsWithBotPermission ) ) {
+ if ( count( $groupsWithBotPermission ) ) {
$tables[] = 'user_groups';
$condition[] = 'ug_group IS NULL';
$join_conds['user_groups'] = array(
@@ -729,12 +787,15 @@
$index = 'usertext_timestamp';
}
}
+
if ( $this->deletedOnly ) {
$condition[] = 'rev_deleted != 0';
}
+
if ( $this->topOnly ) {
$condition[] = 'rev_id = page_latest';
}
+
return array( $tables, $index, $condition, $join_conds );
}
@@ -746,20 +807,20 @@
if ( !$this->associated ) {
return array( "page_namespace $eq_op
$selectedNS" );
- } else {
- $associatedNS = $this->mDb->addQuotes(
- MWNamespace::getAssociated(
$this->namespace )
- );
- return array(
- "page_namespace $eq_op $selectedNS " .
- $bool_op .
- " page_namespace $eq_op $associatedNS"
- );
}
- } else {
- return array();
+ $associatedNS = $this->mDb->addQuotes(
+ MWNamespace::getAssociated( $this->namespace )
+ );
+
+ return array(
+ "page_namespace $eq_op $selectedNS " .
+ $bool_op .
+ " page_namespace $eq_op $associatedNS"
+ );
}
+
+ return array();
}
function getIndexField() {
@@ -773,7 +834,7 @@
$batch = new LinkBatch();
# Give some pointers to make (last) links
foreach ( $this->mResult as $row ) {
- if( isset( $row->rev_parent_id ) && $row->rev_parent_id
) {
+ if ( isset( $row->rev_parent_id ) &&
$row->rev_parent_id ) {
$revIds[] = $row->rev_parent_id;
}
if ( isset( $row->rev_id ) ) {
@@ -830,7 +891,7 @@
*/
wfSuppressWarnings();
$rev = new Revision( $row );
- $validRevision = (bool) $rev->getId();
+ $validRevision = (bool)$rev->getId();
wfRestoreWarnings();
if ( $validRevision ) {
@@ -850,8 +911,8 @@
$topmarktext .= '<span class="mw-uctop">' .
$this->messages['uctop'] . '</span>';
# Add rollback link
if ( !$row->page_is_new && $page->quickUserCan(
'rollback', $user )
- && $page->quickUserCan( 'edit', $user )
)
- {
+ && $page->quickUserCan( 'edit', $user )
+ ) {
$this->preventClickjacking();
$topmarktext .= ' ' .
Linker::generateRollback( $rev, $this->getContext() );
}
@@ -881,11 +942,18 @@
// 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 = ' <span
class="mw-changeslist-separator">. .</span> ' . Linker::formatRevisionSize(
$row->rev_len ) . ' <span class="mw-changeslist-separator">. .</span> ';
+ $chardiff = ' <span
class="mw-changeslist-separator">. .</span> ';
+ $chardiff .= Linker::formatRevisionSize(
$row->rev_len );
+ $chardiff .= ' <span
class="mw-changeslist-separator">. .</span> ';
} else {
$parentLen = isset(
$this->mParentLens[$row->rev_parent_id] ) ?
$this->mParentLens[$row->rev_parent_id] : 0;
- $chardiff = ' <span
class="mw-changeslist-separator">. .</span> ' .
ChangesList::showCharacterDifference(
- $parentLen, $row->rev_len,
$this->getContext() ) . ' <span class="mw-changeslist-separator">. .</span> ';
+ $chardiff = ' <span
class="mw-changeslist-separator">. .</span> ';
+ $chardiff .=
ChangesList::showCharacterDifference(
+ $parentLen,
+ $row->rev_len,
+ $this->getContext()
+ );
+ $chardiff .= ' <span
class="mw-changeslist-separator">. .</span> ';
}
$lang = $this->getLanguage();
@@ -932,7 +1000,9 @@
$del .= ' ';
}
- $diffHistLinks = $this->msg( 'parentheses'
)->rawParams( $difftext . $this->messages['pipe-separator'] . $histlink
)->escaped();
+ $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
@@ -941,7 +1011,10 @@
}
# Tags, if any.
- list( $tagSummary, $newClasses ) =
ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
+ list( $tagSummary, $newClasses ) =
ChangeTags::formatSummaryRow(
+ $row->ts_tags,
+ 'contributions'
+ );
$classes = array_merge( $classes, $newClasses );
$ret .= " $tagSummary";
}
@@ -966,7 +1039,8 @@
*/
function getSqlComment() {
if ( $this->namespace || $this->deletedOnly ) {
- return 'contributions page filtered for namespace or
RevisionDeleted edits'; // potentially slow, see CR r58153
+ // potentially slow, see CR r58153
+ return 'contributions page filtered for namespace or
RevisionDeleted edits';
} else {
return 'contributions page unfiltered';
}
--
To view, visit https://gerrit.wikimedia.org/r/56390
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf1d6fecfbd512fadad61442c968f0ef1ba30a88
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: IAlex <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits