jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358052 )
Change subject: Use short array syntax ...................................................................... Use short array syntax Done by phpcbf over composer fix Change-Id: I5d7e139e4ff21c5a3fdd9d497c33ef82a0dedd88 --- M CentralNotice.hooks.php M CentralNoticeBannerLogPager.php M CentralNoticeCampaignLogPager.php M CentralNoticePageLogPager.php M CentralNoticePager.php M TemplatePager.php M includes/HtmlFormElements/HTMLCentralNoticeBanner.php M includes/HtmlFormElements/HTMLCentralNoticeBannerMessage.php M maintenance/CleanCNTranslateMetadata.php M patches/CNDatabasePatcher.php 10 files changed, 227 insertions(+), 227 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/CentralNotice.hooks.php b/CentralNotice.hooks.php index 1ba1ab4..3c4183e 100644 --- a/CentralNotice.hooks.php +++ b/CentralNotice.hooks.php @@ -105,8 +105,8 @@ global $wgNoticeInfrastructure; if ( $wgNoticeInfrastructure ) { // array( tableName, idField, textField ) - $updateFields[] = array( 'cn_notice_log', 'notlog_user_id' ); - $updateFields[] = array( 'cn_template_log', 'tmplog_user_id' ); + $updateFields[] = [ 'cn_notice_log', 'notlog_user_id' ]; + $updateFields[] = [ 'cn_template_log', 'tmplog_user_id' ]; } return true; } @@ -231,7 +231,7 @@ if ( $wgUser->isAllowed( 'bot' ) ) { $userData = false; } else { - $userData = array(); + $userData = []; // Add the user's registration date (MediaWiki timestamp) $registrationDate = $wgUser->getRegistration() ? $wgUser->getRegistration() : 0; @@ -362,9 +362,9 @@ // Set up test fixtures module, which is added as a dependency for all QUnit // tests. - $testModules['qunit']['ext.centralNotice.testFixtures'] = array( + $testModules['qunit']['ext.centralNotice.testFixtures'] = [ 'class' => 'CNTestFixturesResourceLoaderModule' - ); + ]; // These classes are only used here or in phpunit tests $wgAutoloadClasses['CNTestFixturesResourceLoaderModule'] = @@ -373,10 +373,10 @@ $wgAutoloadClasses['CentralNoticeTestFixtures'] = __DIR__ . '/tests/CentralNoticeTestFixtures.php'; - $testModuleBoilerplate = array( + $testModuleBoilerplate = [ 'localBasePath' => __DIR__, 'remoteExtPath' => 'CentralNotice', - ); + ]; // find test files for every RL module $prefix = 'ext.centralNotice'; @@ -385,7 +385,7 @@ if ( substr( $key, 0, strlen( $prefix ) ) === $prefix && isset( $module['scripts'] ) ) { - $testFiles = array(); + $testFiles = []; foreach ( ( ( array ) $module['scripts'] ) as $script ) { @@ -403,12 +403,12 @@ if ( count( $testFiles ) > 0 ) { $testModules['qunit']["$key.tests"] = $testModuleBoilerplate + - array( + [ 'dependencies' => - array( $key, 'ext.centralNotice.testFixtures' ), + [ $key, 'ext.centralNotice.testFixtures' ], 'scripts' => $testFiles, - ); + ]; } } } diff --git a/CentralNoticeBannerLogPager.php b/CentralNoticeBannerLogPager.php index bbe2147..f8822d5 100644 --- a/CentralNoticeBannerLogPager.php +++ b/CentralNoticeBannerLogPager.php @@ -19,10 +19,10 @@ * Pull log entries from the database */ function getQueryInfo() { - return array( - 'tables' => array( 'template_log' => 'cn_template_log' ), + return [ + 'tables' => [ 'template_log' => 'cn_template_log' ], 'fields' => '*', - ); + ]; } /** @@ -53,7 +53,7 @@ // Begin log entry primary row $htmlOut = Xml::openElement( 'tr' ); - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top' ] ); if ( $row->tmplog_action !== 'removed' ) { $collapsedImg = $this->getLanguage()->isRtl() ? 'collapsed-rtl.png' : @@ -69,19 +69,19 @@ '</a>'; } $htmlOut .= Xml::closeElement( 'td' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $lang->date( $row->tmplog_timestamp ) . ' ' . $lang->time( $row->tmplog_timestamp ) ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $this->msg( 'centralnotice-user-links', $userLink, $userTalkLink )->text() ); // Give grep a chance to find the usages: // centralnotice-action-created, centralnotice-action-modified, // centralnotice-action-removed - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $this->msg( 'centralnotice-action-'.$row->tmplog_action )->text() ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $bannerLink ); @@ -90,11 +90,11 @@ htmlspecialchars( $row->tmplog_comment ) : ' '; $htmlOut .= Xml::tags( 'td', - array( 'valign' => 'top', 'class' => 'primary-summary' ), + [ 'valign' => 'top', 'class' => 'primary-summary' ], $summary ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], ' ' ); @@ -104,12 +104,12 @@ if ( $row->tmplog_action !== 'removed' ) { // Begin log entry secondary row $htmlOut .= Xml::openElement( 'tr', - array( 'id' => 'cn-log-details-'.$row->tmplog_id, 'style' => 'display:none;' ) ); + [ 'id' => 'cn-log-details-'.$row->tmplog_id, 'style' => 'display:none;' ] ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], ' ' // force a table cell in older browsers ); - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '5' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top', 'colspan' => '5' ] ); if ( $row->tmplog_action == 'created' ) { $htmlOut .= $this->showInitialSettings( $row ); } elseif ( $row->tmplog_action == 'modified' ) { @@ -126,25 +126,25 @@ function getStartBody() { $htmlOut = ''; - $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ] ); $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), + $htmlOut .= Xml::element( 'th', [ 'style' => 'width: 20px;' ] ); + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 130px;' ], $this->msg( 'centralnotice-timestamp' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-user' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 100px;' ], $this->msg( 'centralnotice-action' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-banner' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 250px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 250px;' ], $this->msg( 'centralnotice-change-summary-heading' )->text() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], ' ' ); $htmlOut .= Xml::closeElement( 'tr' ); @@ -204,12 +204,12 @@ if ( $newrow->tmplog_action === 'modified' ) { $db = CNDatabase::getDb(); $oldrow = $db->selectRow( - array( 'cn_template_log' => 'cn_template_log' ), + [ 'cn_template_log' => 'cn_template_log' ], '*', - array( 'tmplog_template_id' => $newrow->tmplog_template_id, - "tmplog_id < {$newrow->tmplog_id}" ), + [ 'tmplog_template_id' => $newrow->tmplog_template_id, + "tmplog_id < {$newrow->tmplog_id}" ], __METHOD__, - array( 'ORDER BY' => 'tmplog_id DESC', 'LIMIT' => 1 ) + [ 'ORDER BY' => 'tmplog_id DESC', 'LIMIT' => 1 ] ); } diff --git a/CentralNoticeCampaignLogPager.php b/CentralNoticeCampaignLogPager.php index 902a3a2..9ac31e9 100644 --- a/CentralNoticeCampaignLogPager.php +++ b/CentralNoticeCampaignLogPager.php @@ -9,7 +9,7 @@ // Override paging defaults list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' ); - $this->mLimitsShown = array( 20, 50, 100 ); + $this->mLimitsShown = [ 20, 50, 100 ]; $this->viewPage = SpecialPage::getTitleFor( 'CentralNotice' ); } @@ -42,11 +42,11 @@ $filterUser = $request->getVal( 'user' ); $reset = $request->getVal( 'centralnoticelogreset' ); - $info = array( - 'tables' => array( 'notice_log' => 'cn_notice_log' ), + $info = [ + 'tables' => [ 'notice_log' => 'cn_notice_log' ], 'fields' => '*', - 'conds' => array() - ); + 'conds' => [] + ]; if ( !$reset ) { if ( $filterStartDate > 0 ) { @@ -96,17 +96,17 @@ $campaignLink = Linker::linkKnown( $this->viewPage, htmlspecialchars( $row->notlog_not_name ), - array(), - array( + [], + [ 'subaction' => 'noticeDetail', 'notice' => $row->notlog_not_name - ) + ] ); // Begin log entry primary row $htmlOut = Xml::openElement( 'tr' ); - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top' ] ); if ( $row->notlog_action !== 'removed' ) { $collapsedImg = $this->getLanguage()->isRtl() ? 'collapsed-rtl.png' : @@ -120,20 +120,20 @@ '</a>'; } $htmlOut .= Xml::closeElement( 'td' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $lang->date( $row->notlog_timestamp ) . $this->msg( 'word-separator' )->plain() . $lang->time( $row->notlog_timestamp ) ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $this->msg( 'centralnotice-user-links', $userLink, $userTalkLink )->text() ); // Give grep a chance to find the usages: // centralnotice-action-created, centralnotice-action-modified, // centralnotice-action-removed - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $this->msg( 'centralnotice-action-'.$row->notlog_action )->text() ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $campaignLink ); @@ -142,11 +142,11 @@ $row->notlog_comment : ' '; $htmlOut .= Xml::tags( 'td', - array( 'valign' => 'top', 'class' => 'primary-summary' ), + [ 'valign' => 'top', 'class' => 'primary-summary' ], $summary ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], ' ' ); @@ -156,12 +156,12 @@ if ( $row->notlog_action !== 'removed' ) { // Begin log entry secondary row $htmlOut .= Xml::openElement( 'tr', - array( 'id' => 'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ) ); + [ 'id' => 'cn-log-details-'.$row->notlog_id, 'style' => 'display:none;' ] ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], ' ' // force a table cell in older browsers ); - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top', 'colspan' => '6' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top', 'colspan' => '6' ] ); if ( $row->notlog_action == 'created' ) { $htmlOut .= $this->showInitialSettings( $row ); } elseif ( $row->notlog_action == 'modified' ) { @@ -292,8 +292,8 @@ // Show changes to banner weights and assignment $beginBannersObject = json_decode( $row->notlog_begin_banners, true ); $endBannersObject = json_decode( $row->notlog_end_banners, true ); - $beginBanners = array(); - $endBanners = array(); + $beginBanners = []; + $endBanners = []; foreach( $beginBannersObject as $key => $params ) { if ( is_array( $params ) ) { $weight = $params['weight']; @@ -371,8 +371,8 @@ if ( $row->$beginField !== $row->$endField ) { $lang = $this->getLanguage(); - $beginSet = array(); - $endSet = array(); + $beginSet = []; + $endSet = []; if ( $row->$beginField ) { $beginSet = explode( ', ', $row->$beginField ); } @@ -507,25 +507,25 @@ */ function getStartBody() { $htmlOut = ''; - $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ] ); $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), + $htmlOut .= Xml::element( 'th', [ 'style' => 'width: 20px;' ] ); + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 130px;' ], $this->msg( 'centralnotice-timestamp' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-user' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 100px;' ], $this->msg( 'centralnotice-action' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-notice' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 250px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 250px;' ], $this->msg( 'centralnotice-change-summary-heading' )->text() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], ' ' ); $htmlOut .= Xml::closeElement( 'tr' ); diff --git a/CentralNoticePageLogPager.php b/CentralNoticePageLogPager.php index 8a2ddb9..617d6a3 100644 --- a/CentralNoticePageLogPager.php +++ b/CentralNoticePageLogPager.php @@ -32,27 +32,27 @@ * Pull log entries from the database */ function getQueryInfo() { - $conds = array( + $conds = [ 'rc_bot' => 1, // include bot edits (all edits made by CentralNotice are bot edits) 'rc_namespace' => 8, // only MediaWiki pages - ); + ]; if ( $this->logType == 'bannercontent' ) { // Add query contitions for banner content log - $conds += array( + $conds += [ "rc_title LIKE 'Centralnotice-template-%'", // get banner content - ); + ]; } else { // Add query contitions for banner messages log - $conds += array( + $conds += [ "rc_title LIKE 'Centralnotice-%'", // get banner messages "rc_title NOT LIKE 'Centralnotice-template-%'", // exclude normal banner content - ); + ]; } - return array( - 'tables' => array( 'recentchanges' ), + return [ + 'tables' => [ 'recentchanges' ], 'fields' => '*', 'conds' => $conds, // WHERE conditions - ); + ]; } /** @@ -93,8 +93,8 @@ $bannerLink = Linker::linkKnown( $this->viewPage, htmlspecialchars( $banner ), - array(), - array( 'template' => $banner ) + [], + [ 'template' => $banner ] ); // Create title object @@ -106,11 +106,11 @@ if ( $row->rc_new ) { $bannerCell = $bannerLink; } else { - $querydiff = array( + $querydiff = [ 'curid' => $row->rc_cur_id, 'diff' => $row->rc_this_oldid, 'oldid' => $row->rc_last_oldid - ); + ]; $diffUrl = htmlspecialchars( $title->getLinkUrl( $querydiff ) ); // Should "diff" be localised? It appears not to be elsewhere in the interface. // See ChangesList->preCacheMessages() for example. @@ -127,11 +127,11 @@ if ( $row->rc_new ) { $messageCell = $messageLink; } else { - $querydiff = array( + $querydiff = [ 'curid' => $row->rc_cur_id, 'diff' => $row->rc_this_oldid, 'oldid' => $row->rc_last_oldid - ); + ]; $diffUrl = htmlspecialchars( $title->getLinkUrl( $querydiff ) ); // Should "diff" be localised? It appears not to be elsewhere in the interface. // See ChangesList->preCacheMessages() for example. @@ -143,30 +143,30 @@ $lang = $this->getLanguage(); $htmlOut = Xml::openElement( 'tr' ); - $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) ); + $htmlOut .= Xml::openElement( 'td', [ 'valign' => 'top' ] ); $htmlOut .= Xml::closeElement( 'td' ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $lang->date( $row->rc_timestamp ) . ' ' . $lang->time( $row->rc_timestamp ) ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $this->msg( 'centralnotice-user-links', $userLink, $userTalkLink )->text() ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $bannerCell ); if ( $this->logType == 'bannermessages' ) { - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $messageCell ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'primary' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'primary' ], $language ); } $htmlOut .= Xml::tags( 'td', - array( 'valign' => 'top', 'class' => 'primary-summary' ), + [ 'valign' => 'top', 'class' => 'primary-summary' ], htmlspecialchars( $row->rc_comment ) ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], ' ' ); @@ -181,23 +181,23 @@ */ function getStartBody() { $htmlOut = ''; - $htmlOut .= Xml::openElement( 'table', array( 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'id' => 'cn-campaign-logs', 'cellpadding' => 3 ] ); $htmlOut .= Xml::openElement( 'tr' ); - $htmlOut .= Xml::element( 'th', array( 'style' => 'width: 20px;' ) ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 130px;' ), + $htmlOut .= Xml::element( 'th', [ 'style' => 'width: 20px;' ] ); + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 130px;' ], $this->msg ( 'centralnotice-timestamp' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-user' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-banner' )->text() ); if ( $this->logType == 'bannermessages' ) { - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 160px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 160px;' ], $this->msg( 'centralnotice-message' )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'style' => 'width: 100px;' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'style' => 'width: 100px;' ], $this->msg( 'centralnotice-language' )->text() ); @@ -208,11 +208,11 @@ } $htmlOut .= Xml::element( 'th', - array( 'align' => 'left', 'style' => "width: {$commentWidth};" ), + [ 'align' => 'left', 'style' => "width: {$commentWidth};" ], $this->msg( 'centralnotice-change-summary-heading' )->text() ); - $htmlOut .= Xml::tags( 'td', array(), + $htmlOut .= Xml::tags( 'td', [], ' ' ); $htmlOut .= Xml::closeElement( 'tr' ); diff --git a/CentralNoticePager.php b/CentralNoticePager.php index 80509f3..f95a672 100644 --- a/CentralNoticePager.php +++ b/CentralNoticePager.php @@ -24,7 +24,7 @@ $likeArray = $dbr->anyString(); } else { $anyStringToken = $dbr->anyString(); - $tempArray = array( $anyStringToken ); + $tempArray = [ $anyStringToken ]; foreach ( $likeArray as $likePart ) { $tempArray[ ] = $likePart; $tempArray[ ] = $anyStringToken; @@ -38,37 +38,37 @@ if ( $noticeId ) { // Return all the banners not already assigned to the current campaign - return array( - 'tables' => array( + return [ + 'tables' => [ 'assignments' => 'cn_assignments', 'templates' => 'cn_templates', - ), + ], - 'fields' => array( + 'fields' => [ 'templates.tmp_name', 'templates.tmp_id', - ), + ], - 'conds' => array( + 'conds' => [ 'assignments.tmp_id IS NULL', 'tmp_name' . $dbr->buildLike( $likeArray ) - ), + ], - 'join_conds' => array( - 'assignments' => array( + 'join_conds' => [ + 'assignments' => [ 'LEFT JOIN', "assignments.tmp_id = templates.tmp_id " . "AND assignments.not_id = $noticeId" - ) - ) - ); + ] + ] + ]; } else { // Return all the banners in the database - return array( - 'tables' => array( 'templates' => 'cn_templates'), - 'fields' => array( 'templates.tmp_name', 'templates.tmp_id' ), - 'conds' => array( 'templates.tmp_name' . $dbr->buildLike( $likeArray ) ), - ); + return [ + 'tables' => [ 'templates' => 'cn_templates'], + 'fields' => [ 'templates.tmp_name', 'templates.tmp_id' ], + 'conds' => [ 'templates.tmp_name' . $dbr->buildLike( $likeArray ) ], + ]; } } @@ -81,17 +81,17 @@ if ( $this->editable ) { // Add box - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), - Xml::check( 'addTemplates[]', '', array( 'value' => $row->tmp_name ) ) + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], + Xml::check( 'addTemplates[]', '', [ 'value' => $row->tmp_name ] ) ); // Bucket - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $this->bucketDropDown( $row->tmp_name ) ); // Weight select - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top', 'class' => 'cn-weight' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top', 'class' => 'cn-weight' ], Xml::listDropDown( "weight[$row->tmp_id]", CentralNotice::dropDownList( $this->msg( 'centralnotice-weight' )->text(), range( 0, 100, 5 ) @@ -107,7 +107,7 @@ $banner = Banner::fromName( $row->tmp_name ); $bannerRenderer = new BannerRenderer( $this->getContext(), $banner ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $bannerRenderer->linkTo() . "<br>" . $bannerRenderer->previewFieldSet() ); @@ -124,21 +124,21 @@ */ function getStartBody() { $htmlOut = ''; - $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'cellpadding' => 9 ] ); $htmlOut .= Xml::openElement( 'tr' ); if ( $this->editable ) { - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'width' => '5%' ], $this->msg( "centralnotice-add" )->text() ); - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'width' => '5%' ], $this->msg( 'centralnotice-bucket' )->text() ); $htmlOut .= Xml::element( 'th', - array( 'align' => 'left', 'width' => '5%', 'class' => 'cn-weight' ), + [ 'align' => 'left', 'width' => '5%', 'class' => 'cn-weight' ], $this->msg( 'centralnotice-weight' )->text() ); } - $htmlOut .= Xml::element( 'th', array( 'align' => 'left' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left' ], $this->msg( 'centralnotice-templates' )->text() ); $htmlOut .= Xml::closeElement( 'tr' ); @@ -158,12 +158,12 @@ global $wgNoticeNumberOfBuckets; // class should coordinate with CentralNotice::bucketDropDown() - $html = Html::openElement( 'select', array( + $html = Html::openElement( 'select', [ 'name' => "bucket-{$bannerName}", - 'class' => array( 'bucketSelector' ), - ) ); + 'class' => [ 'bucketSelector' ], + ] ); foreach ( range( 0, $wgNoticeNumberOfBuckets - 1 ) as $value ) { - $html .= Xml::option( chr( $value + ord( 'A' ) ), $value, false, array() ); + $html .= Xml::option( chr( $value + ord( 'A' ) ), $value, false, [] ); } $html .= Html::closeElement( 'select' ); return $html; diff --git a/TemplatePager.php b/TemplatePager.php index 56c19de..94b5e18 100644 --- a/TemplatePager.php +++ b/TemplatePager.php @@ -20,7 +20,7 @@ // Override paging defaults list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' ); - $this->mLimitsShown = array( 20, 50, 100 ); + $this->mLimitsShown = [ 20, 50, 100 ]; $msg = Xml::encodeJsVar( $this->msg( 'centralnotice-confirm-delete' )->text() ); $this->onRemoveChange = "if( this.checked ) { this.checked = confirm( $msg ) }"; @@ -43,7 +43,7 @@ $likeArray = $dbr->anyString(); } else { $anyStringToken = $dbr->anyString(); - $tempArray = array( $anyStringToken ); + $tempArray = [ $anyStringToken ]; foreach ( $likeArray as $likePart ) { $tempArray[ ] = $likePart; $tempArray[ ] = $anyStringToken; @@ -51,11 +51,11 @@ $likeArray = $tempArray; } - return array( - 'tables' => array( 'templates' => 'cn_templates'), - 'fields' => array( 'templates.tmp_name', 'templates.tmp_id' ), - 'conds' => array( 'templates.tmp_name' . $dbr->buildLike( $likeArray ) ), - ); + return [ + 'tables' => [ 'templates' => 'cn_templates'], + 'fields' => [ 'templates.tmp_name', 'templates.tmp_id' ], + 'conds' => [ 'templates.tmp_name' . $dbr->buildLike( $likeArray ) ], + ]; } /** @@ -80,12 +80,12 @@ if ( $this->editable ) { // Remove box - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], Xml::check( 'removeTemplates[]', false, - array( + [ 'value' => $row->tmp_name, 'onchange' => $this->onRemoveChange - ) + ] ) ); } @@ -94,7 +94,7 @@ $banner = Banner::fromName( $row->tmp_name ); $bannerRenderer = new BannerRenderer( $this->getContext(), $banner ); - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), + $htmlOut .= Xml::tags( 'td', [ 'valign' => 'top' ], $bannerRenderer->linkTo() . "<br>" . $bannerRenderer->previewFieldSet() ); @@ -111,14 +111,14 @@ */ function getStartBody() { $htmlOut = ''; - $htmlOut .= Xml::openElement( 'table', array( 'cellpadding' => 9 ) ); + $htmlOut .= Xml::openElement( 'table', [ 'cellpadding' => 9 ] ); $htmlOut .= Xml::openElement( 'tr' ); if ( $this->editable ) { - $htmlOut .= Xml::element( 'th', array( 'align' => 'left', 'width' => '5%' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left', 'width' => '5%' ], $this->msg( 'centralnotice-remove' )->text() ); } - $htmlOut .= Xml::element( 'th', array( 'align' => 'left' ), + $htmlOut .= Xml::element( 'th', [ 'align' => 'left' ], $this->msg( 'centralnotice-templates' )->text() ); $htmlOut .= Xml::closeElement( 'tr' ); @@ -136,7 +136,7 @@ if ( $this->editable ) { $htmlOut .= Html::hidden( 'authtoken', $this->getUser()->getEditToken() ); $htmlOut .= Xml::tags( 'div', - array( 'class' => 'cn-buttons' ), + [ 'class' => 'cn-buttons' ], Xml::submitButton( $this->msg( 'centralnotice-modify' )->text() ) ); } diff --git a/includes/HtmlFormElements/HTMLCentralNoticeBanner.php b/includes/HtmlFormElements/HTMLCentralNoticeBanner.php index a892d7d..e5b52f4 100644 --- a/includes/HtmlFormElements/HTMLCentralNoticeBanner.php +++ b/includes/HtmlFormElements/HTMLCentralNoticeBanner.php @@ -51,18 +51,18 @@ $previewUrl = $wgNoticeBannerPreview . "/{$bannerName}/{$bannerName}_{$language}.png"; $preview = Html::element( 'img', - array( + [ 'src' => $previewUrl, 'alt' => $bannerName, - ) + ] ); return Xml::tags( 'div', - array( + [ 'id' => Sanitizer::escapeId( "cn-banner-preview-$bannerName" ), 'class' => 'cn-banner-preview-div', - ), + ], $preview ); } @@ -91,34 +91,34 @@ $html = Xml::openElement( 'div', - array( + [ 'id' => Sanitizer::escapeId( "cn-banner-list-element-{$this->mParams['banner']}" ), 'class' => "cn-banner-list-element", - ) + ] ); // Make the label; this consists of a text link to the banner editor, // and a series of status icons if ( array_key_exists( 'withlabel', $this->mParams ) ) { $bannerName = $this->mParams['banner']; - $html .= Xml::openElement( 'div', array( 'class' => 'cn-banner-list-element-label' ) ); + $html .= Xml::openElement( 'div', [ 'class' => 'cn-banner-list-element-label' ] ); $html .= Linker::link( SpecialPage::getTitleFor( 'CentralNoticeBanners', "edit/$bannerName" ), htmlspecialchars( $bannerName ), - array( 'class' => 'cn-banner-list-element-label-text' ) + [ 'class' => 'cn-banner-list-element-label-text' ] ); $html .= ' (' . Linker::link( SpecialPage::getTitleFor( 'Randompage' ), $this->msg( 'centralnotice-live-preview' ), - array( 'class' => 'cn-banner-list-element-label-text' ), - array( + [ 'class' => 'cn-banner-list-element-label-text' ], + [ 'banner' => $bannerName, 'uselang' => $language, 'force' => '1' - ) + ] ) . ')'; // TODO: Output status icons - $html .= Xml::tags( 'div', array( 'class' => 'cn-banner-list-element-label-icons' ), '' ); + $html .= Xml::tags( 'div', [ 'class' => 'cn-banner-list-element-label-icons' ], '' ); $html .= Xml::closeElement( 'div' ); } diff --git a/includes/HtmlFormElements/HTMLCentralNoticeBannerMessage.php b/includes/HtmlFormElements/HTMLCentralNoticeBannerMessage.php index b79277b..0e01fd6 100644 --- a/includes/HtmlFormElements/HTMLCentralNoticeBannerMessage.php +++ b/includes/HtmlFormElements/HTMLCentralNoticeBannerMessage.php @@ -52,18 +52,18 @@ $message = new BannerMessage( $this->mParams[ 'banner' ], $this->mParams[ 'message' ] ); - $html = Xml::openElement( 'table', array( 'class' => 'cn-message-table' ) ); + $html = Xml::openElement( 'table', [ 'class' => 'cn-message-table' ] ); $html .= Xml::openElement( 'tr' ); $originText = $message->getContents( $wgContLang->getCode() ); $html .= Xml::element( 'td', - array( 'class' => 'cn-message-text-origin' ), + [ 'class' => 'cn-message-text-origin' ], $originText ); $this->mParams[ 'placeholder' ] = $originText; - $html .= Xml::openElement( 'td', array( 'class' => 'cn-message-text-native' ) ); + $html .= Xml::openElement( 'td', [ 'class' => 'cn-message-text-native' ] ); $html .= parent::getInputHTML( $message->getContents( $this->mParams[ 'language' ] ) ); $html .= Xml::closeElement( 'td' ); diff --git a/maintenance/CleanCNTranslateMetadata.php b/maintenance/CleanCNTranslateMetadata.php index ef5dcf3..947081c 100644 --- a/maintenance/CleanCNTranslateMetadata.php +++ b/maintenance/CleanCNTranslateMetadata.php @@ -45,14 +45,14 @@ $res = $db->select( 'revtag', - array( + [ 'rt_page', 'maxrev' => 'max(rt_revision)', 'count' => 'count(*)' - ), - array( 'rt_type' => $this->ttag ), + ], + [ 'rt_type' => $this->ttag ], __METHOD__, - array( 'GROUP BY' => 'rt_page' ) + [ 'GROUP BY' => 'rt_page' ] ); foreach ( $res as $row ) { @@ -62,11 +62,11 @@ $db->delete( 'revtag', - array( + [ 'rt_type' => $this->ttag, 'rt_page' => $row->rt_page, "rt_revision != {$row->maxrev}" - ), + ], __METHOD__ ); $numRows = $db->affectedRows(); @@ -85,15 +85,15 @@ $db = CNDatabase::getDb( DB_MASTER ); $res = $db->select( - array( 'revtag' => 'revtag', 'page' => 'page', 'cn_templates' => 'cn_templates' ), - array( 'rt_page', 'rt_revision', 'page_title', 'tmp_id' ), - array( + [ 'revtag' => 'revtag', 'page' => 'page', 'cn_templates' => 'cn_templates' ], + [ 'rt_page', 'rt_revision', 'page_title', 'tmp_id' ], + [ 'rt_type' => $this->ttag, 'rt_page=page_id', 'rt_value is null', # Length of "centralnotice-template-" 'tmp_name=substr(page_title, 24)' - ), + ], __METHOD__ ); @@ -102,12 +102,12 @@ "with revtag with page id {$row->rt_page}\n" ); $db->update( 'revtag', - array( 'rt_value' => $row->tmp_id ), - array( + [ 'rt_value' => $row->tmp_id ], + [ 'rt_type' => $this->ttag, 'rt_page' => $row->rt_page, 'rt_value is null' - ), + ], __METHOD__ ); } @@ -122,8 +122,8 @@ $res = $db->select( 'revtag', - array( 'rt_page', 'rt_revision' ), - array( 'rt_type' => $this->ttag, 'rt_value is null' ), + [ 'rt_page', 'rt_revision' ], + [ 'rt_type' => $this->ttag, 'rt_value is null' ], __METHOD__ ); @@ -131,12 +131,12 @@ $this->output( " -- Deleting orphan row {$row->rt_page}:{$row->rt_revision}\n" ); $db->delete( 'revtag', - array( + [ 'rt_type' => $this->ttag, 'rt_page' => $row->rt_page, 'rt_revision' => $row->rt_revision, 'rt_value is null' // Just in case something updated it - ), + ], __METHOD__ ); } diff --git a/patches/CNDatabasePatcher.php b/patches/CNDatabasePatcher.php index 6bcfeda..ff7dd63 100644 --- a/patches/CNDatabasePatcher.php +++ b/patches/CNDatabasePatcher.php @@ -22,158 +22,158 @@ if ( $updater->getDB()->getType() == 'mysql' ) { $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notices', $base . '/../CentralNotice.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_notices', 'not_preferred', $base . '/patch-notice_preferred.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notice_languages', $base . '/patch-notice_languages.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_templates', 'tmp_display_anon', $base . '/patch-template_settings.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_templates', 'tmp_fundraising', $base . '/patch-template_fundraising.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notice_countries', $base . '/patch-notice_countries.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notice_projects', $base . '/patch-notice_projects.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notice_log', $base . '/patch-notice_log.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_template_log', $base . '/patch-template_log.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_templates', 'tmp_autolink', $base . '/patch-template_autolink.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_template_log', 'tmplog_begin_prioritylangs', $base . '/patch-prioritylangs.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_notices', 'not_buckets', $base . '/patch-bucketing.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_template_mixins', $base . '/patch-centralnotice-2_3.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_template_mixins', 'mixin_name', $base . '/patch-mixin_modules.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_template_log', 'tmplog_begin_devices', $base . '/patch-template-device-logging.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addIndex', 'cn_templates', 'tmp_category', $base . '/patch-custom-groups.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_notices', 'not_throttle', $base . '/patch-campaign_throttle.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ /* This is a hack... we're adding rows not modifying a field */ 'modifyField', 'cn_known_devices', 'dev_name', $base . '/patch-add_devices.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_template_log', 'tmplog_comment', $base . '/patch-template-logging-comments.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_notice_log', 'notlog_comment', $base . '/patch-notice-logging-comments.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addIndex', 'cn_assignments', 'asn_bucket', $base . '/patch-assignments_index.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notice_mixins', $base . '/patch-notice-mixins.sql', true - ) + ] ); $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notice_mixin_params', $base . '/patch-notice-mixins-params.sql', true - ) + ] ); // This adds both notlog_begin_mixins and notlog_end_mixins fields $updater->addExtensionUpdate( - array( + [ 'addField', 'cn_notice_log', 'notlog_begin_mixins', $base . '/patch-notice-mixins-log.sql', true - ) + ] ); } elseif ( $updater->getDB()->getType() == 'sqlite' ) { // Add the entire schema... $updater->addExtensionUpdate( - array( + [ 'addTable', 'cn_notices', $base . '/../CentralNotice.sql', true - ) + ] ); } return true; -- To view, visit https://gerrit.wikimedia.org/r/358052 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5d7e139e4ff21c5a3fdd9d497c33ef82a0dedd88 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/CentralNotice Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org> Gerrit-Reviewer: Ejegg <ej...@ejegg.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits