jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/358043 )
Change subject: Make phpcs pass - includes
......................................................................
Make phpcs pass - includes
Change-Id: I915a6702a26721b8da82a59be6958d344543cefd
---
M includes/Banner.php
M includes/BannerMessageGroup.php
M includes/BannerRenderer.php
M includes/CNBannerPager.php
M includes/CNCampaignPager.php
M includes/CNChoiceDataResourceLoaderModule.php
M includes/CNDeviceTarget.php
M includes/Campaign.php
M includes/CampaignLog.php
M includes/ChoiceDataProvider.php
M includes/GeoTarget.php
M includes/MixinController.php
12 files changed, 81 insertions(+), 70 deletions(-)
Approvals:
jenkins-bot: Verified
Thiemo Mättig (WMDE): Looks good to me, approved
diff --git a/includes/Banner.php b/includes/Banner.php
index 2a331d6..e9b0d90 100644
--- a/includes/Banner.php
+++ b/includes/Banner.php
@@ -57,7 +57,7 @@
'prioritylang' => null,
);
- //<editor-fold desc="Properties">
+ // <editor-fold desc="Properties">
// !!! NOTE !!! It is not recommended to use directly. It is almost
always more
// correct to use the accessor/setter function.
@@ -93,9 +93,9 @@
protected $bodyContent = '';
protected $runTranslateJob = false;
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Constructors">
+ // <editor-fold desc="Constructors">
/**
* Create a banner object from a known ID. Must already be
* an object in the database. If a fully new banner is to be created
@@ -153,9 +153,9 @@
return $obj;
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Basic metadata getters/setters">
+ // <editor-fold desc="Basic metadata getters/setters">
/**
* Get the unique ID for this banner.
*
@@ -392,9 +392,9 @@
);
}
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Device targeting">
+ // <editor-fold desc="Device targeting">
/**
* Get the devices that this banner should be allocated to.
*
@@ -468,7 +468,7 @@
__METHOD__
);
- foreach( $rowObj as $row ) {
+ foreach ( $rowObj as $row ) {
$this->devices[ intval( $row->dev_id ) ] =
$row->dev_name;
}
@@ -502,9 +502,9 @@
}
}
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Mixin management">
+ // <editor-fold desc="Mixin management">
/**
* @return array Keys are names of enabled mixins; valeus are mixin
params.
* @see $wgCentralNoticeBannerMixins
@@ -616,9 +616,9 @@
}
}
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Priority languages">
+ // <editor-fold desc="Priority languages">
/**
* Returns language codes that are considered a priority for
translations.
*
@@ -692,9 +692,9 @@
);
}
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Banner body content">
+ // <editor-fold desc="Banner body content">
public function getDbKey() {
$name = $this->getName();
return "Centralnotice-template-{$name}";
@@ -799,9 +799,9 @@
}
}
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Banner message fields">
+ // <editor-fold desc="Banner message fields">
function getMessageField( $field_name ) {
return new BannerMessage( $this->getName(), $field_name );
}
@@ -914,10 +914,10 @@
}
return array_keys( $availableLangs );
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc="Banner actions">
- //<editor-fold desc="Saving">
+ // <editor-fold desc="Banner actions">
+ // <editor-fold desc="Saving">
/**
* Saves any changes made to the banner object into the database
*
@@ -957,7 +957,9 @@
$db->endAtomic( __METHOD__ );
// Clear the dirty flags
- foreach ( $this->dirtyFlags as $flag => &$value ) {
$value = false; }
+ foreach ( $this->dirtyFlags as $flag => &$value ) {
+ $value = false;
+ }
if ( $this->runTranslateJob ) {
// Must be run after banner has finished saving
due to some dependencies that
@@ -1007,7 +1009,7 @@
$this->saveMixinData( $db );
$this->savePriorityLanguageData();
}
- //</editor-fold>
+ // </editor-fold>
/**
* Archive a banner.
@@ -1115,9 +1117,9 @@
}
}
}
- //</editor-fold>
+ // </editor-fold>
- //<editor-fold desc=" Random stuff that still needs to die a hideous
horrible death">
+ // <editor-fold desc=" Random stuff that still needs to die a hideous
horrible death">
/**
* Add a revision tag for the banner
* @param string $tag The name of the tag
@@ -1262,7 +1264,7 @@
'anon' => (int)$banner->allocateToAnon(),
'account' =>
(int)$banner->allocateToLoggedIn(),
// TODO: Death to this!
- 'fundraising' => (int)($banner->getCategory() ===
'fundraising'),
+ 'fundraising' => (int)( $banner->getCategory() ===
'fundraising' ),
'category' => $banner->getCategory(),
'controller_mixin' => implode( ",", array_keys(
$banner->getMixins() ) ),
'devices' => array_values(
$banner->getDevices() ),
@@ -1322,7 +1324,6 @@
$banner['fundraising'] = (int) $row->fundraising;
- //XXX
$banner['devices'] = array( "desktop" );
return $banner;
}
@@ -1418,7 +1419,7 @@
$dbw->insert( 'cn_template_log', $log );
}
- //</editor-fold>
+ // </editor-fold>
/**
* Validation function for banner names. Will return true iff the name
fits
@@ -1460,6 +1461,11 @@
}
}
-class BannerDataException extends Exception {}
-class BannerContentException extends BannerDataException {}
-class BannerExistenceException extends BannerDataException {}
+class BannerDataException extends Exception {
+}
+
+class BannerContentException extends BannerDataException {
+}
+
+class BannerExistenceException extends BannerDataException {
+}
diff --git a/includes/BannerMessageGroup.php b/includes/BannerMessageGroup.php
index 35ced52..62313c0 100644
--- a/includes/BannerMessageGroup.php
+++ b/includes/BannerMessageGroup.php
@@ -74,8 +74,7 @@
$msgDefKeyPrefix = "Centralnotice-{$this->bannerName}-";
if ( $this->namespace == NS_CN_BANNER ) {
$msgKeyPrefix = $this->bannerName . '-';
- }
- else {
+ } else {
$msgKeyPrefix = $msgDefKeyPrefix;
}
@@ -159,9 +158,8 @@
BannerMessageGroup::updateBannerGroupStateHook(
$subgroup, $code, $currentState,
$newState );
}
- }
- elseif ( ( $group instanceof BannerMessageGroup )
- && in_array( $newState,
$wgNoticeTranslateDeployStates )
+ } elseif ( ( $group instanceof BannerMessageGroup )
+ && in_array( $newState, $wgNoticeTranslateDeployStates )
) {
// Finally an object we can deal with directly and it's
in the right state!
$collection = $group->initCollection( $code );
@@ -188,8 +186,7 @@
);
}
}
- }
- else {
+ } else {
// We do nothing; we don't care about this type of
group; or it's in the wrong state
}
diff --git a/includes/BannerRenderer.php b/includes/BannerRenderer.php
index 8bd5216..d682d22 100644
--- a/includes/BannerRenderer.php
+++ b/includes/BannerRenderer.php
@@ -48,7 +48,7 @@
$this->mixinController = new MixinController( $this->context,
$this->banner->getMixins() );
- //FIXME: it should make sense to do this:
+ // FIXME: it should make sense to do this:
// $this->mixinController->registerMagicWord( 'campaign',
array( $this, 'getCampaign' ) );
// $this->mixinController->registerMagicWord( 'banner', array(
$this, 'getBanner' ) );
}
diff --git a/includes/CNBannerPager.php b/includes/CNBannerPager.php
index 739e4f2..b206ac6 100644
--- a/includes/CNBannerPager.php
+++ b/includes/CNBannerPager.php
@@ -94,7 +94,7 @@
}
return array(
- 'tables' => array( 'templates' => 'cn_templates'),
+ 'tables' => array( 'templates' => 'cn_templates' ),
'fields' => array( 'templates.tmp_name',
'templates.tmp_id' ),
'conds' => array( 'templates.tmp_name' .
$this->mDb->buildLike( $likeArray ) ),
);
@@ -123,7 +123,7 @@
$bannerName = $row->tmp_name;
// Add the prepend prototypes
- foreach( $this->prependPrototypes as $prototypeName =>
$prototypeValues ) {
+ foreach ( $this->prependPrototypes as $prototypeName =>
$prototypeValues ) {
$retval[ "{$prototypeName}-{$bannerName}" ] =
$prototypeValues;
if ( array_key_exists( 'id', $prototypeValues ) ) {
$retval[ "{$prototypeName}-{$bannerId}" ][ 'id'
] .= "-$bannerName";
@@ -141,7 +141,7 @@
}
// Append prototypes
- foreach( $this->appendPrototypes as $prototypeName =>
$prototypeValues ) {
+ foreach ( $this->appendPrototypes as $prototypeName =>
$prototypeValues ) {
$retval[ $prototypeName . "-$bannerId" ] =
$prototypeValues;
if ( array_key_exists( 'id', $prototypeValues ) ) {
$retval[ $prototypeName . "-$bannerId" ][ 'id'
] .= "-$bannerId";
@@ -150,7 +150,7 @@
// Set the disabled attribute
if ( !$this->editable ) {
- foreach( $retval as $prototypeName => $prototypeValues
) {
+ foreach ( $retval as $prototypeName => $prototypeValues
) {
$retval[ $prototypeName ][ 'disabled' ] = true;
}
}
@@ -216,7 +216,9 @@
class HTMLBannerPagerNavigation extends HTMLFormField {
/** Empty - no validation can be done on a navigation element */
- function validate( $value, $alldata ) { return true; }
+ function validate( $value, $alldata ) {
+ return true;
+ }
public function getInputHTML( $value ) {
return $this->mParams['value'];
diff --git a/includes/CNCampaignPager.php b/includes/CNCampaignPager.php
index 7a5a13e..5eec1d9 100644
--- a/includes/CNCampaignPager.php
+++ b/includes/CNCampaignPager.php
@@ -113,7 +113,6 @@
parent::doQuery();
}
-
/**
* @see TablePager::getFieldNames()
*/
@@ -236,7 +235,7 @@
);
case 'not_throttle':
- if ( $value < 100) {
+ if ( $value < 100 ) {
return $value . "%";
} else {
return '';
diff --git a/includes/CNChoiceDataResourceLoaderModule.php
b/includes/CNChoiceDataResourceLoaderModule.php
index 674c731..d7c19ab 100644
--- a/includes/CNChoiceDataResourceLoaderModule.php
+++ b/includes/CNChoiceDataResourceLoaderModule.php
@@ -67,14 +67,14 @@
array( 'timeout' => self::API_REQUEST_TIMEOUT * 0.8 ) );
if ( !$apiResult ) {
- wfLogWarning( 'Couldn\'t get banner choice data via
API.');
+ wfLogWarning( 'Couldn\'t get banner choice data via
API.' );
return false;
}
$parsedApiResult = FormatJson::parse( $apiResult,
FormatJson::FORCE_ASSOC );
if ( !$parsedApiResult->isGood() ) {
- wfLogWarning( 'Couldn\'t parse banner choice data from
API.');
+ wfLogWarning( 'Couldn\'t parse banner choice data from
API.' );
return false;
}
diff --git a/includes/CNDeviceTarget.php b/includes/CNDeviceTarget.php
index 6a40141..b171ef7 100644
--- a/includes/CNDeviceTarget.php
+++ b/includes/CNDeviceTarget.php
@@ -23,7 +23,7 @@
array( 'dev_id', 'dev_name', 'dev_display_label' )
);
- foreach( $res as $row ) {
+ foreach ( $res as $row ) {
if ( $flip ) {
$devices[ $row->dev_name ] = array(
'label' => $row->dev_display_label,
@@ -66,7 +66,7 @@
__METHOD__
);
- foreach( $res as $row ) {
+ foreach ( $res as $row ) {
$devices[ intval( $row->dev_id ) ] = $row->dev_name;
}
diff --git a/includes/Campaign.php b/includes/Campaign.php
index 4715981..7dd9111 100644
--- a/includes/Campaign.php
+++ b/includes/Campaign.php
@@ -206,7 +206,7 @@
// Get campaign info from database
$row = $db->selectRow(
- array('notices' => 'cn_notices'),
+ array( 'notices' => 'cn_notices' ),
array(
'not_id',
'not_name',
@@ -376,7 +376,7 @@
// Get campaign info from database
$row = $dbr->selectRow(
- array('notices' => 'cn_notices'),
+ array( 'notices' => 'cn_notices' ),
array(
'not_id',
'not_start',
@@ -506,7 +506,7 @@
$campaign['banners'] = FormatJson::decode(
$campaign['banners'], true );
if ( !is_array( current( $campaign['banners'] )
) ) {
// Old log format; only had weight
- foreach( $campaign['banners'] as $key
=> &$value ) {
+ foreach ( $campaign['banners'] as $key
=> &$value ) {
$value = array(
'weight' => $value,
'bucket' => 0
@@ -522,7 +522,7 @@
$historical_banner =
Banner::getHistoricalBanner( $name, $ts );
if ( $historical_banner === null ) {
- //FIXME: crazy hacks
+ // FIXME: crazy hacks
$historical_banner =
Banner::getBannerSettings( $name );
$historical_banner['label'] =
wfMessage( 'centralnotice-damaged-log', $name );
$historical_banner['display_anon'] =
$historical_banner['anon'];
@@ -1424,4 +1424,5 @@
}
}
-class CampaignExistenceException extends Exception {}
+class CampaignExistenceException extends Exception {
+}
diff --git a/includes/CampaignLog.php b/includes/CampaignLog.php
index 07e1147..9c8af04 100644
--- a/includes/CampaignLog.php
+++ b/includes/CampaignLog.php
@@ -14,16 +14,22 @@
$begin = array();
$end = array();
if ( $row ) {
+ $comma_explode = function( $str ) {
+ return explode( ", ", $str );
+ };
- $comma_explode = function( $str ) { return explode( ",
", $str ); };
- $json_decode = function( $json ) { return json_decode(
$json, true ); };
+ $json_decode = function( $json ) {
+ return json_decode( $json, true );
+ };
$store = function( $name, $decode = null ) use ( $row,
&$begin, &$end ) {
$beginField = 'notlog_begin_' . $name;
$endField = 'notlog_end_' . $name;
if ( !$decode ) {
- $decode = function($v) { return $v; };
+ $decode = function( $v ) {
+ return $v;
+ };
}
$begin[ $name ] = $decode( $row->$beginField );
$end[ $name ] = $decode( $row->$endField );
diff --git a/includes/ChoiceDataProvider.php b/includes/ChoiceDataProvider.php
index 6bded56..71eeea5 100644
--- a/includes/ChoiceDataProvider.php
+++ b/includes/ChoiceDataProvider.php
@@ -21,7 +21,6 @@
$cache->makeGlobalKey( self::CACHE_KEY_NAMESPACE,
'check' ) );
}
-
/**
* Get a data structure with the allocation choices.
*
@@ -51,7 +50,7 @@
// campaigns are updated, the cache is
invalidated, and
// a client queries a yet-unsynced slave DB.
Also, gracefully
// fail if we're running an old version of core
(<1.27).
- if ( method_exists( 'Database',
'getCacheSetOptions') ) {
+ if ( method_exists( 'Database',
'getCacheSetOptions' ) ) {
$setOpts +=
Database::getCacheSetOptions( $dbr );
}
@@ -161,8 +160,8 @@
// and {{{banner}}} in banner categories. (These are
the magic
// words mentioned in the CN Admin UI.)
$category = $dbRow->tmp_category;
- $category = str_replace( '{{{campaign}}}',
$campaignName, $category);
- $category = str_replace( '{{{banner}}}', $bannerName,
$category);
+ $category = str_replace( '{{{campaign}}}',
$campaignName, $category );
+ $category = str_replace( '{{{banner}}}', $bannerName,
$category );
$category = Banner::sanitizeRenderedCategory( $category
);
// The first time we see any campaign, create the
corresponding
@@ -205,7 +204,7 @@
}
// If there's nothing, return the empty array now
- if ( count ( $choices ) === 0 ) {
+ if ( count( $choices ) === 0 ) {
return $choices;
}
@@ -221,7 +220,7 @@
'notices.not_id',
'notice_countries.nc_country'
),
- array (
+ array(
'notices.not_geo' => 1,
'notices.not_id' => array_keys( $choices )
),
@@ -248,7 +247,7 @@
// Add campaign-associated mixins to the data structure
foreach ( $choices as &$campaignInfo ) {
- //Get info for enabled mixins for this campaign
+ // Get info for enabled mixins for this campaign
$campaignInfo['mixins'] =
Campaign::getCampaignMixins(
$campaignInfo['name'], true );
}
diff --git a/includes/GeoTarget.php b/includes/GeoTarget.php
index 7fb279c..0d01982 100644
--- a/includes/GeoTarget.php
+++ b/includes/GeoTarget.php
@@ -266,16 +266,16 @@
}
// And we need to add MaxMind specific countries:
http://www.maxmind.com/en/iso3166
- $countries['EU'] =
wfMessage('centralnotice-country-eu')->inContentLanguage()->text();
- $countries['AP'] =
wfMessage('centralnotice-country-ap')->inContentLanguage()->text();
- $countries['A1'] =
wfMessage('centralnotice-country-a1')->inContentLanguage()->text();
- $countries['A2'] =
wfMessage('centralnotice-country-a2')->inContentLanguage()->text();
- $countries['O1'] =
wfMessage('centralnotice-country-o1')->inContentLanguage()->text();
+ $countries['EU'] = wfMessage( 'centralnotice-country-eu'
)->inContentLanguage()->text();
+ $countries['AP'] = wfMessage( 'centralnotice-country-ap'
)->inContentLanguage()->text();
+ $countries['A1'] = wfMessage( 'centralnotice-country-a1'
)->inContentLanguage()->text();
+ $countries['A2'] = wfMessage( 'centralnotice-country-a2'
)->inContentLanguage()->text();
+ $countries['O1'] = wfMessage( 'centralnotice-country-o1'
)->inContentLanguage()->text();
// We will also add country 'XX' which is a MW specific 'fake'
country for when GeoIP
// does not return any results at all or when something else
odd has happened (IE: we
// fail to parse the country.)
- $countries['XX'] =
wfMessage('centralnotice-country-unknown')->inContentLanguage()->text();
+ $countries['XX'] = wfMessage( 'centralnotice-country-unknown'
)->inContentLanguage()->text();
asort( $countries );
diff --git a/includes/MixinController.php b/includes/MixinController.php
index 4e9f9ec..60a5bc5 100644
--- a/includes/MixinController.php
+++ b/includes/MixinController.php
@@ -49,7 +49,8 @@
foreach ( $this->mixins as $name => $info ) {
if ( !empty( $info['preloadJs'] ) ) {
$filename = $info['localBasePath'] .
DIRECTORY_SEPARATOR . $info['preloadJs'];
- if ( !( $snippet = file_get_contents( $filename
) ) ) {
+ $snippet = file_get_contents( $filename );
+ if ( !$snippet ) {
throw new MixinNotFoundException( $name
);
}
$snippets[$name] = $snippet;
--
To view, visit https://gerrit.wikimedia.org/r/358043
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I915a6702a26721b8da82a59be6958d344543cefd
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits