jenkins-bot has submitted this change and it was merged.
Change subject: Build: Test PHP code quality with mediawiki-codesniffer
......................................................................
Build: Test PHP code quality with mediawiki-codesniffer
Also remove non existing i18n php file from languageStats.php file.
Change-Id: I8ce507668e81e324d2453e2f1d98bdc297deaa99
---
M UploadWizard.config.php
M UploadWizard.php
M composer.json
M includes/ApiFlickrBlacklist.php
M includes/ApiQueryAllCampaigns.php
M includes/CampaignContent.php
M includes/CampaignHooks.php
M includes/CampaignPageFormatter.php
M includes/UploadWizardCampaign.php
M includes/UploadWizardConfig.php
M includes/UploadWizardFlickrBlacklist.php
M includes/UploadWizardTutorial.php
M includes/specials/SpecialCampaigns.php
M includes/specials/SpecialUploadWizard.php
M languageStats.php
M maintenance/migrateCampaigns.php
A phpcs.xml
M tests/phpunit/ApiFlickrBlacklistTest.php
M tests/phpunit/UploadWizardConfigTest.php
19 files changed, 210 insertions(+), 92 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/UploadWizard.config.php b/UploadWizard.config.php
index 657078e..36ae3d7 100644
--- a/UploadWizard.config.php
+++ b/UploadWizard.config.php
@@ -4,7 +4,8 @@
* Do not modify this file, instead use localsettings.php and set:
* $wgUploadWizardConfig[ 'name'] = 'value';
*/
-global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules,
$wgMaxUploadSize, $wgLang, $wgMemc, $wgUploadWizardConfig,
$wgCheckFileExtensions;
+global $wgFileExtensions, $wgServer, $wgScriptPath, $wgAPIModules,
$wgMaxUploadSize, $wgLang,
+ $wgMemc, $wgUploadWizardConfig, $wgCheckFileExtensions;
$userLangCode = $wgLang->getCode();
// We need to get a list of languages for the description dropdown.
@@ -19,7 +20,10 @@
// First, get a list of languages we support.
$baseLangs = Language::fetchLanguageNames( $userLangCode, 'all' );
// We need to take into account languageTemplateFixups
- if ( is_array( $wgUploadWizardConfig ) && array_key_exists(
'languageTemplateFixups', $wgUploadWizardConfig ) ) {
+ if (
+ is_array( $wgUploadWizardConfig ) &&
+ array_key_exists( 'languageTemplateFixups',
$wgUploadWizardConfig )
+ ) {
$languageFixups =
$wgUploadWizardConfig['languageTemplateFixups'];
if ( !is_array( $languageFixups ) ) {
$languageFixups = array();
@@ -30,7 +34,7 @@
// Use LinkBatch to make this a little bit more faster.
// It works because $title->exists (below) will use LinkCache.
$linkBatch = new LinkBatch();
- foreach( $baseLangs as $code => $name ) {
+ foreach ( $baseLangs as $code => $name ) {
$fixedCode = array_key_exists( $code, $languageFixups ) ?
$languageFixups[$code] : $code;
if ( is_string( $fixedCode ) && $fixedCode !== '' ) {
$title = Title::makeTitle( NS_TEMPLATE,
Title::capitalize( $fixedCode, NS_TEMPLATE ) );
@@ -51,7 +55,7 @@
}
}
// Sort the list by the language name
- natsort($uwLanguages);
+ natsort( $uwLanguages );
// Cache the list for 1 day
$wgMemc->set( $cacheKey, $uwLanguages, 60 * 60 * 24 );
}
@@ -82,10 +86,15 @@
'fileExtensions' => $wgCheckFileExtensions ? $wgFileExtensions : null,
// Flickr details
- // Flickr API is SSL-only as of June 27th, 2014:
http://code.flickr.net/2014/04/30/flickr-api-going-ssl-only-on-june-27th-2014/
+ // Flickr API is SSL-only as of June 27th, 2014:
+ //
http://code.flickr.net/2014/04/30/flickr-api-going-ssl-only-on-june-27th-2014/
'flickrApiUrl' => 'https://api.flickr.com/services/rest/?',
- 'flickrApiKey' => 'aeefff139445d825d4460796616f9349', // you should
probably replace this with your own
- 'flickrBlacklistPage' => '', // name of wiki page with blacklist of
Flickr users
+
+ // you should probably replace this with your own
+ 'flickrApiKey' => 'aeefff139445d825d4460796616f9349',
+
+ // name of wiki page with blacklist of Flickr users
+ 'flickrBlacklistPage' => '',
// Settings about things that get automatically (and silently) added to
uploads
'autoAdd' => array(
@@ -97,8 +106,8 @@
),
// If the user didn't add categories, or removed the default
categories, add this wikitext.
- // Use this to indicate that some human should categorize this file.
Does not consider autoAdd.categories,
- // which are hidden.
+ // Use this to indicate that some human should categorize this file.
+ // Does not consider autoAdd.categories, which are hidden.
'missingCategoriesWikiText' => '',
'display' => array(
@@ -174,7 +183,7 @@
// If the type above is select, provide a dictionary of
// value -> label associations to display as options
- 'options' => array(/* 'value' => 'label' */)
+ 'options' => array( /* 'value' => 'label' */ )
)
),
@@ -184,6 +193,8 @@
// Initial value for the description field.
'description' => '',
+
+ // @codingStandardsIgnoreStart
// These values are commented out by default, so they can be
undefined
// Define them here if you want defaults.
@@ -202,6 +213,8 @@
//// Initial value for the heading field.
//'heading' => 0,
+
+ // @codingStandardsIgnoreEnd
),
// 'uwLanguages' is a list of languages and codes, for use in the
description step.
@@ -545,23 +558,27 @@
// Max file size that is allowed by MediaWiki. This limit can never be
ignored.
'maxMwUploadSize' => $wgMaxUploadSize,
- // Minimum length of custom wikitext for a license, if used. It is 6
because at minimum it needs four chars for opening and closing
+ // Minimum length of custom wikitext for a license, if used.
+ // It is 6 because at minimum it needs four chars for opening and
closing
// braces, then two chars for a license, e.g. {{xx}}
'minCustomLicenseLength' => 6,
// Maximum length of custom wikitext for a license
'maxCustomLicenseLength' => 10000,
+ // @codingStandardsIgnoreStart
// The UploadWizard allows users to provide file descriptions in
multiple languages. For each description, the user
// can choose the language. The UploadWizard wraps each description in
a "language template". A language template is
// by default assumed to be a template with a name corresponding to the
ISO 646 code of the language. For instance,
- // Template:en for English, or Template:fr for French. This mechanism is
used for instance at Wikimedia Commons.
+ // Template:en for English, or Template:fr for French. This mechanism
is used for instance at Wikimedia Commons.
// If this is not the case for some or all or your wiki's language
templates, this map can be used to define the
// template names to be used. Keys are ISO 646 language codes, values
are template names. The default defines the
// exceptions used at Wikimedia Commons: the language template for
Tagalog (ISO 646 code 'tl') is not named 'tl'
// but 'tgl' for historical reasons.
+ // @codingStandardsIgnoreEnd
'languageTemplateFixups' => $uwDefaultLanguageFixups,
+ // @codingStandardsIgnoreStart
// XXX this is horribly confusing -- some file restrictions are
client side, others are server side
// the filename prefix blacklist is at least server side -- all
this should be replaced with PHP regex config
// or actually, in an ideal world, we'd have some way to
reliably detect gibberish, rather than trying to
@@ -574,11 +591,14 @@
// /^(test|image|img|bild|example?[\s_-]*)$/, // test
stuff
// /^(\d{10}[\s_-][0-9a-f]{10}[\s_-][a-z])$/ // flickr
// ]
+ // @codingStandardsIgnoreEnd
+ // @codingStandardsIgnoreStart
// Check if we want to enable firefogg, will result in
// 1) firefogg install recommendation when users try to upload media
asset with an extension in the
// transcodeExtensionList
// 2) Once the user installs firefogg it is used for encoding videos
that are not in supported formats before handing it off to
mw.ApiUploadFormDataHandler for upload
+ // @codingStandardsIgnoreEnd
'enableFirefogg' => true,
// Setup list of video extensions for recomending firefogg.
@@ -600,12 +620,14 @@
// Defaults to UploadWizard's bug tracker.
// If you want to use a wiki page, set this to a falsy value,
// and set feedbackPage to the name of the wiki page.
-
+ // @codingStandardsIgnoreStart
'feedbackLink' =>
'https://phabricator.wikimedia.org/maniphest/task/create/?projects=MediaWiki-extensions-UploadWizard',
+ // @codingStandardsIgnoreEnd
- // [deprecated] Wiki page for leaving Upload Wizard feedback, for
example 'Commons:Upload wizard feedback'
+ // [deprecated] Wiki page for leaving Upload Wizard feedback,
+ // for example 'Commons:Upload wizard feedback'
'feedbackPage' => '',
-
+ // @codingStandardsIgnoreStart
// Title of page for alternative uploading form, e.g.:
// 'altUploadForm' => 'Special:Upload',
//
@@ -616,6 +638,7 @@
// 'default' => 'Commons:Upload',
// 'de' => 'Commons:Hochladen'
// );
+ // @codingStandardsIgnoreEnd
'altUploadForm' => '',
// Is titleBlacklist API even available?
diff --git a/UploadWizard.php b/UploadWizard.php
index c73ed8c..96a830a 100644
--- a/UploadWizard.php
+++ b/UploadWizard.php
@@ -122,7 +122,7 @@
'messages' => 'mwe-upwiz-transport-started',
) + $uploadWizardModuleInfo;
-//upload using FormData, large files in chunks
+// upload using FormData, large files in chunks
$wgResourceModules['ext.uploadWizard.apiUploadFormDataHandler'] = array(
'scripts' => 'handlers/mw.ApiUploadFormDataHandler.js',
'dependencies' => 'ext.uploadWizard.formDataTransport',
@@ -184,7 +184,8 @@
$wgUploadWizardConfig = array();
/* Define and configure default namespaces, as defined on Mediawiki.org
- * https://www.mediawiki.org/wiki/Extension_default_namespaces#UploadWizard */
+ * https://www.mediawiki.org/wiki/Extension_default_namespaces#UploadWizard
+ */
define( 'NS_CAMPAIGN', 460 );
define( 'NS_CAMPAIGN_TALK', 461 );
$wgExtraNamespaces[ NS_CAMPAIGN ] = 'Campaign';
diff --git a/composer.json b/composer.json
index f2883f7..4365e8a 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,12 @@
{
"require-dev": {
- "jakub-onderka/php-parallel-lint": "0.9"
+ "jakub-onderka/php-parallel-lint": "0.9",
+ "mediawiki/mediawiki-codesniffer": "0.4.0"
},
"scripts": {
"test": [
- "parallel-lint . --exclude vendor"
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
]
}
}
diff --git a/includes/ApiFlickrBlacklist.php b/includes/ApiFlickrBlacklist.php
index 533d5ed..2e1280b 100644
--- a/includes/ApiFlickrBlacklist.php
+++ b/includes/ApiFlickrBlacklist.php
@@ -71,8 +71,10 @@
*/
public function getExamples() {
return array(
+ // @codingStandardsIgnoreStart
'api.php?action=flickrblacklist&url=http%3A//farm1.staticflickr.com/44/147426941_98baf36fd1_o.jpg',
'api.php?action=flickrblacklist&list',
+ // @codingStandardsIgnoreEnd
);
}
diff --git a/includes/ApiQueryAllCampaigns.php
b/includes/ApiQueryAllCampaigns.php
index 4332d4c..63eb0f7 100644
--- a/includes/ApiQueryAllCampaigns.php
+++ b/includes/ApiQueryAllCampaigns.php
@@ -51,7 +51,8 @@
if ( !is_null( $params['continue'] ) ) {
$from_id = (int)$params['continue'];
- $this->addWhere( "campaign_id >= $from_id" ); // Not
SQL Injection, since we already force this to be an integer
+ // Not SQL Injection, since we already force this to be
an integer
+ $this->addWhere( "campaign_id >= $from_id" );
}
$res = $this->select( __METHOD__ );
@@ -121,7 +122,8 @@
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'continue' => array(
- /** @todo Once support for MediaWiki < 1.25 is
dropped, just use ApiBase::PARAM_HELP_MSG directly */
+ /** @todo Once support for MediaWiki < 1.25 is
dropped,
+ just use ApiBase::PARAM_HELP_MSG directly */
constant( 'ApiBase::PARAM_HELP_MSG' ) ?: '' =>
'api-help-param-continue',
),
);
diff --git a/includes/CampaignContent.php b/includes/CampaignContent.php
index 04f4012..4fceb83 100644
--- a/includes/CampaignContent.php
+++ b/includes/CampaignContent.php
@@ -31,7 +31,7 @@
throw new JsonSchemaException( wfMessage(
'eventlogging-invalid-json' )->parse() );
}
- $schema = include( __DIR__ . '/CampaignSchema.php' );
+ $schema = include ( __DIR__ . '/CampaignSchema.php' );
// Only validate fields we care about
$campaignFields = array_keys( $schema['properties'] );
@@ -47,7 +47,7 @@
}
$mergedConfig = UploadWizardConfig::array_replace_sanely(
$defaultCampaignConfig, $campaign );
- return efSchemaValidate( $mergedConfig , $schema );
+ return efSchemaValidate( $mergedConfig, $schema );
}
/**
diff --git a/includes/CampaignHooks.php b/includes/CampaignHooks.php
index e2ca1f1..ebb1b83 100644
--- a/includes/CampaignHooks.php
+++ b/includes/CampaignHooks.php
@@ -15,7 +15,10 @@
* Sets up appropriate entries in the uc_campaigns table for each
Campaign
* Acts everytime a page in the NS_CAMPAIGN namespace is saved
*/
- public static function onPageContentSaveComplete( $article, $user,
$content, $summary, $isMinor, $isWatch, $section, $flags, $revision, $status,
$baseRevId ) {
+ public static function onPageContentSaveComplete(
+ $article, $user, $content, $summary, $isMinor, $isWatch,
+ $section, $flags, $revision, $status, $baseRevId
+ ) {
if ( !$article->getTitle()->inNamespace( NS_CAMPAIGN ) ) {
return true;
}
@@ -35,7 +38,6 @@
array( 'campaign_name' ),
$insertData
);
-
$campaign = new UploadWizardCampaign( $article->getTitle(),
$content->getJsonData() );
@@ -57,7 +59,9 @@
}
$success = $success && $dbw->delete( 'templatelinks', array(
'tl_from' => $article->getId() ) );
- $success = $success && $dbw->insert( 'templatelinks',
$insertions, __METHOD__, array( 'IGNORE' ) );
+ $success = $success && $dbw->insert(
+ 'templatelinks', $insertions, __METHOD__, array(
'IGNORE' )
+ );
$dbw->commit();
@@ -73,8 +77,8 @@
*
* This is usually run via the Job Queue mechanism.
*/
- public static function onLinksUpdateComplete( LinksUpdate
&$linksupdate) {
- if( !$linksupdate->getTitle()->inNamespace( NS_CAMPAIGN ) ) {
+ public static function onLinksUpdateComplete( LinksUpdate &$linksupdate
) {
+ if ( !$linksupdate->getTitle()->inNamespace( NS_CAMPAIGN ) ) {
return true;
}
@@ -86,7 +90,9 @@
/**
* Deletes entries from uc_campaigns table when a Campaign is deleted
*/
- public static function onArticleDeleteComplete( $article, $user,
$reason, $id, $content, $logEntry ) {
+ public static function onArticleDeleteComplete(
+ $article, $user, $reason, $id, $content, $logEntry
+ ) {
if ( !$article->getTitle()->inNamespace( NS_CAMPAIGN ) ) {
return true;
}
diff --git a/includes/CampaignPageFormatter.php
b/includes/CampaignPageFormatter.php
index a21168a..d4c976d 100644
--- a/includes/CampaignPageFormatter.php
+++ b/includes/CampaignPageFormatter.php
@@ -34,7 +34,9 @@
public function generateReadHtml() {
$config = $this->campaign->getParsedConfig();
- $campaignTitle = array_key_exists( 'title', $config ) ?
$config['title'] : $this->campaign->getName();
+ $campaignTitle = array_key_exists( 'title', $config ) ?
+ $config['title'] :
+ $this->campaign->getName();
$campaignDescription = array_key_exists( 'description', $config
) ? $config['description'] : '';
$campaignViewMoreLink =
$this->campaign->getTrackingCategory()->getFullURL();
@@ -44,7 +46,9 @@
$gallery->setHeights( 180 );
$gallery->setShowBytes( false );
- $this->context->getOutput()->setSquidMaxage(
UploadWizardConfig::getSetting( 'campaignSquidMaxAge' ) );
+ $this->context->getOutput()->setSquidMaxage(
+ UploadWizardConfig::getSetting( 'campaignSquidMaxAge' )
+ );
$this->context->getOutput()->setHTMLTitle( $this->context->msg(
'pagetitle', $campaignTitle ) );
$images = $this->campaign->getUploadedMedia();
@@ -63,7 +67,9 @@
wfMessage(
'mwe-upwiz-campaign-create-account-button' )->text()
);
} else {
- $uploadUrl = Skin::makeSpecialUrl( 'UploadWizard',
array( 'campaign' => $this->campaign->getName() ) );
+ $uploadUrl = Skin::makeSpecialUrl(
+ 'UploadWizard', array( 'campaign' =>
$this->campaign->getName() )
+ );
$uploadLink =
Html::element( 'a',
array( 'class' =>
'mw-ui-big mw-ui-button mw-ui-primary', 'href' => $uploadUrl ),
@@ -72,7 +78,11 @@
}
if ( count( $images ) === 0 ) {
- $body = Html::element( 'div', array( 'id' =>
'mw-campaign-no-uploads-yet' ), wfMessage( 'mwe-upwiz-campaign-no-uploads-yet'
)->plain() );
+ $body = Html::element(
+ 'div',
+ array( 'id' => 'mw-campaign-no-uploads-yet' ),
+ wfMessage( 'mwe-upwiz-campaign-no-uploads-yet'
)->plain()
+ );
} else {
foreach ( $images as $image ) {
$gallery->add( $image );
@@ -82,9 +92,15 @@
Html::rawElement( 'div', array( 'id' =>
'mw-campaign-images' ), $gallery->toHTML() ) .
Html::rawElement( 'a',
array( 'id' => 'mw-campaign-view-all',
'href' => $campaignViewMoreLink ),
- Html::rawElement( 'span', array(
'class' => 'mw-campaign-chevron mw-campaign-float-left' ), ' ' ) .
+ Html::rawElement(
+ 'span',
+ array( 'class' =>
'mw-campaign-chevron mw-campaign-float-left' ), ' '
+ ) .
wfMessage(
'mwe-upwiz-campaign-view-all-media' )->escaped() .
- Html::rawElement( 'span', array(
'class' => 'mw-campaign-chevron mw-campaign-float-right' ), ' ' )
+ Html::rawElement(
+ 'span',
+ array( 'class' =>
'mw-campaign-chevron mw-campaign-float-right' ), ' '
+ )
);
}
@@ -96,7 +112,7 @@
$this->context->getLanguage()->formatNum( $uploaderCount ) ) .
Html::element( 'span',
array( 'class' =>
'mw-campaign-number-desc' ),
- wfMessage(
'mwe-upwiz-campaign-contributors-count-desc')
+ wfMessage(
'mwe-upwiz-campaign-contributors-count-desc' )
->numParams( $uploaderCount )
->text()
)
@@ -120,11 +136,11 @@
$campaignExpensiveStats .
Html::rawElement( 'div', array(
'class' => 'mw-campaign-number-container' ),
Html::element( 'div',
array( 'class' => 'mw-campaign-number' ),
-
$this->context->getLanguage()->formatNum( $uploadCount )
+
$this->context->getLanguage()->formatNum( $uploadCount )
) .
Html::element( 'span',
array( 'class'
=> 'mw-campaign-number-desc' ),
- wfMessage(
'mwe-upwiz-campaign-media-count-desc')
+ wfMessage(
'mwe-upwiz-campaign-media-count-desc' )
->numParams(
$uploadCount )
->text()
)
diff --git a/includes/UploadWizardCampaign.php
b/includes/UploadWizardCampaign.php
index 872401a..638e118 100755
--- a/includes/UploadWizardCampaign.php
+++ b/includes/UploadWizardCampaign.php
@@ -116,7 +116,9 @@
public function getTrackingCategory() {
$trackingCats = UploadWizardConfig::getSetting(
'trackingCategory' );
- return Title::makeTitleSafe( NS_CATEGORY, str_replace( '$1',
$this->getName(), $trackingCats['campaign'] ) );
+ return Title::makeTitleSafe(
+ NS_CATEGORY, str_replace( '$1', $this->getName(),
$trackingCats['campaign'] )
+ );
}
public function getUploadedMediaCount() {
@@ -249,7 +251,7 @@
$parsed = array();
foreach ( $array as $key => $value ) {
if ( $forKeys !== null ) {
- if( in_array( $key, $forKeys ) ) {
+ if ( in_array( $key, $forKeys ) ) {
if ( is_array( $value ) ) {
$parsed[$key] =
$this->parseArrayValues( $value, $lang );
} else {
@@ -282,7 +284,9 @@
// timestamp is greater than or equal to the timestamp of the
last time an invalidate was
// issued.
$cache = ObjectCache::getMainWANInstance();
- $memKey = wfMemcKey( 'uploadwizard', 'campaign',
$this->getName(), 'parsed-config', $lang->getCode() );
+ $memKey = wfMemcKey(
+ 'uploadwizard', 'campaign', $this->getName(),
'parsed-config', $lang->getCode()
+ );
$depKeys = array( $this->makeInvalidateTimestampKey() );
$curTTL = null;
@@ -357,9 +361,9 @@
foreach ( $this->parsedConfig as $cnf => $modifiers ) {
if ( $cnf === 'whileActive' && $this->isActive() ) {
$activeModifiers = $modifiers;
- } else if ( $cnf === 'afterActive' &&
$this->wasActive() ) {
+ } elseif ( $cnf === 'afterActive' && $this->wasActive()
) {
$activeModifiers = $modifiers;
- } else if ( $cnf === 'beforeActive' ) {
+ } elseif ( $cnf === 'beforeActive' ) {
$activeModifiers = $modifiers;
}
}
@@ -411,7 +415,9 @@
* @return String
*/
private function makeInvalidateTimestampKey() {
- return wfMemcKey( 'uploadwizard', 'campaign', $this->getName(),
'parsed-config', 'invalidate-timestamp' );
+ return wfMemcKey(
+ 'uploadwizard', 'campaign', $this->getName(),
'parsed-config', 'invalidate-timestamp'
+ );
}
/**
@@ -420,10 +426,14 @@
*/
private function isActive() {
$today = strtotime( date( "Y-m-d" ) );
- $start = array_key_exists( 'start', $this->parsedConfig ) ?
strtotime( $this->parsedConfig['start'] ) : null;
- $end = array_key_exists( 'end', $this->parsedConfig ) ?
strtotime( $this->parsedConfig['end'] ) : null;
+ $start = array_key_exists(
+ 'start', $this->parsedConfig
+ ) ? strtotime( $this->parsedConfig['start'] ) : null;
+ $end = array_key_exists(
+ 'end', $this->parsedConfig
+ ) ? strtotime( $this->parsedConfig['end'] ) : null;
- return ($start === null || $start <= $today ) && ($end === null
|| $end > $today );
+ return ( $start === null || $start <= $today ) && ( $end ===
null || $end > $today );
}
/**
@@ -432,7 +442,9 @@
*/
private function wasActive() {
$today = strtotime( date( "Y-m-d" ) );
- $start = array_key_exists( 'start', $this->parsedConfig ) ?
strtotime( $this->parsedConfig['start'] ) : null;
+ $start = array_key_exists(
+ 'start', $this->parsedConfig
+ ) ? strtotime( $this->parsedConfig['start'] ) : null;
return $start === null || $start <= $today;
}
@@ -462,7 +474,7 @@
private function applyObjectReferenceToButtons( $objRef ) {
$customizableButtons = array( 'homeButton', 'beginButton' );
- foreach( $customizableButtons as $button ) {
+ foreach ( $customizableButtons as $button ) {
if ( array_key_exists( $button,
$this->parsedConfig['display'] ) &&
$this->parsedConfig['display'][$button]['target'] === 'useObjref'
) {
diff --git a/includes/UploadWizardConfig.php b/includes/UploadWizardConfig.php
index ca1d206..a022a82 100644
--- a/includes/UploadWizardConfig.php
+++ b/includes/UploadWizardConfig.php
@@ -20,7 +20,7 @@
* @return boolean
*/
private static function is_assoc( $array ) {
- return ( bool )count( array_filter( array_keys( $array ),
'is_string' ) );
+ return (bool)count( array_filter( array_keys( $array ),
'is_string' ) );
}
/* Same functionality as array_merge_recursive, but sanely
@@ -79,14 +79,19 @@
static $mergedConfig = false;
if ( !$mergedConfig ) {
- $wgUploadWizardConfig =
UploadWizardConfig::array_replace_sanely( self::getDefaultConfig(),
$wgUploadWizardConfig );
+ $wgUploadWizardConfig =
UploadWizardConfig::array_replace_sanely(
+ self::getDefaultConfig(),
+ $wgUploadWizardConfig
+ );
$mergedConfig = true;
}
if ( !is_null( $campaignName ) ) {
- $wgUploadWizardConfig =
UploadWizardConfig::array_replace_sanely( $wgUploadWizardConfig,
self::getCampaignConfig( $campaignName ) );
+ $wgUploadWizardConfig =
UploadWizardConfig::array_replace_sanely(
+ $wgUploadWizardConfig,
+ self::getCampaignConfig( $campaignName )
+ );
}
-
return array_replace_recursive( $wgUploadWizardConfig,
self::$urlConfig );
}
@@ -128,7 +133,7 @@
*/
protected static function getDefaultConfig() {
$configPath = dirname( __DIR__ ) . '/UploadWizard.config.php';
- return is_file( $configPath ) ? include( $configPath ) :
array();
+ return is_file( $configPath ) ? include ( $configPath ) :
array();
}
/**
diff --git a/includes/UploadWizardFlickrBlacklist.php
b/includes/UploadWizardFlickrBlacklist.php
index 63df217..3c2266f 100644
--- a/includes/UploadWizardFlickrBlacklist.php
+++ b/includes/UploadWizardFlickrBlacklist.php
@@ -147,4 +147,4 @@
}
return $userIds;
}
-}
\ No newline at end of file
+}
diff --git a/includes/UploadWizardTutorial.php
b/includes/UploadWizardTutorial.php
index 48a99af..2f0fe73 100644
--- a/includes/UploadWizardTutorial.php
+++ b/includes/UploadWizardTutorial.php
@@ -42,11 +42,14 @@
// at this point, we have one of the following situations:
// $error is null, and tutorialFile is the right one for this
language
- // $error notes we couldn't find the tutorialFile for your
language, and $tutorialFile is the english one
- // $error notes we couldn't find the tutorialFile for your
language, and $tutorialFile is still false (major file failure)
+ // $error notes we couldn't find the tutorialFile for your
language,
+ // and $tutorialFile is the english one
+ // $error notes we couldn't find the tutorialFile for your
language,
+ // and $tutorialFile is still false (major file failure)
if ( $tutorialFile ) {
- // XXX TODO if the client can handle SVG, we could also
just send it the unscaled thumb, client-scaled into a DIV or something.
+ // XXX TODO if the client can handle SVG, we could also
just send it the unscaled thumb,
+ // client-scaled into a DIV or something.
// if ( client can handle SVG ) {
// $tutorialThumbnailImage->getUnscaledThumb();
// }
@@ -55,7 +58,7 @@
// n.b. File::transform() returns false if failed,
MediaTransformOutput otherwise
$thumbnailImage = $tutorialFile->transform( array(
'width' => $tutorial['width'] ) );
- if ( $thumbnailImage ) {
+ if ( $thumbnailImage ) {
$tutorialHtml = self::getImageHtml(
$thumbnailImage, $tutorial );
} else {
$error = 'cannot-transform';
@@ -72,7 +75,9 @@
if ( $error === 'localized-file-missing' ) {
$errorMsg->params( Language::fetchLanguageName(
$langCode, $wgLang->getCode() ) );
}
- $errorHtml = Html::element( 'p', array( 'class' =>
'errorbox', 'style' => 'float: none;' ), $errorMsg->text() );
+ $errorHtml = Html::element(
+ 'p', array( 'class' => 'errorbox', 'style' =>
'float: none;' ), $errorMsg->text()
+ );
}
return $errorHtml . $tutorialHtml;
@@ -93,7 +98,8 @@
}
/**
- * Constructs HTML for the tutorial (laboriously), including an
imagemap for the clickable "Help desk" button.
+ * Constructs HTML for the tutorial (laboriously),
+ * including an imagemap for the clickable "Help desk" button.
*
* @param MediaTransformOutput $thumb
* @param String|null $campaign Upload Wizard campaign for which the
tutorial should be displayed.
@@ -104,7 +110,7 @@
$helpDeskUrl = wfMessage( 'mwe-upwiz-help-desk-url' )->text();
// Per convention, we may be either using an absolute URL or a
wiki page title in this UI message
- if( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $helpDeskUrl
)) {
+ if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/',
$helpDeskUrl ) ) {
$helpDeskHref = $helpDeskUrl;
} else {
$helpDeskTitle = Title::newFromText( $helpDeskUrl );
diff --git a/includes/specials/SpecialCampaigns.php
b/includes/specials/SpecialCampaigns.php
index 0a433b8..b61bc6b 100644
--- a/includes/specials/SpecialCampaigns.php
+++ b/includes/specials/SpecialCampaigns.php
@@ -14,7 +14,7 @@
$limit = 50;
- $cond = array('campaign_enabled = 1' );
+ $cond = array( 'campaign_enabled = 1' );
if ( $start !== null ) {
// Not SQL Injection, since $start is cast to (int)
@@ -29,14 +29,14 @@
array( 'LIMIT' => $limit + 1 )
);
- $this->getOutput()->setPageTitle( $this->msg(
'mwe-upload-campaigns-list-title') );
+ $this->getOutput()->setPageTitle( $this->msg(
'mwe-upload-campaigns-list-title' ) );
$this->getOutput()->addModules(
'ext.uploadWizard.uploadCampaign.list' );
$this->getOutput()->addHTML( '<dl>' );
$curCount = 0;
$lastId = null;
- foreach( $res as $row ) {
+ foreach ( $res as $row ) {
$curCount++;
if ( $curCount > $limit ) {
@@ -83,4 +83,4 @@
protected function getGroupName() {
return 'media';
}
-}
\ No newline at end of file
+}
diff --git a/includes/specials/SpecialUploadWizard.php
b/includes/specials/SpecialUploadWizard.php
index 7e7284b..17ac499 100644
--- a/includes/specials/SpecialUploadWizard.php
+++ b/includes/specials/SpecialUploadWizard.php
@@ -61,7 +61,6 @@
}
}
-
$urlArgs = array( 'description', 'lat', 'lon', 'alt' );
$urlDefaults = array();
@@ -112,7 +111,6 @@
$out->addHTML( '<p class="errorbox">' . $this->msg(
'mwe-upwiz-js-off' )->escaped() . '</p>' );
$this->simpleForm->show();
$out->addHTML( '</noscript>' );
-
// global javascript variables
$this->addJsVars( $subPage );
@@ -192,7 +190,8 @@
}
}
}
- // UploadFromUrl parameter set to true only if the user is
allowed to upload a file from a URL which we need to check in our Javascript
implementation.
+ // UploadFromUrl parameter set to true only if the user is
allowed to upload a file
+ // from a URL which we need to check in our Javascript
implementation.
if ( UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed(
$this->getUser() ) === true ) {
$config['UploadFromUrl'] = true;
} else {
@@ -211,13 +210,19 @@
// Determine if the user's default license is valid for
this campaign
switch ( $config['licensing']['ownWorkDefault'] ) {
case "own":
- $defaultInAllowedLicenses = in_array(
$userDefaultLicense, $config['licensing']['ownWork']['licenses'] );
+ $defaultInAllowedLicenses = in_array(
+ $userDefaultLicense,
$config['licensing']['ownWork']['licenses']
+ );
break;
case "notown":
- $defaultInAllowedLicenses = in_array(
$userDefaultLicense, UploadWizardConfig::getThirdPartyLicenses() );
+ $defaultInAllowedLicenses = in_array(
+ $userDefaultLicense,
UploadWizardConfig::getThirdPartyLicenses()
+ );
break;
case "choice":
- $defaultInAllowedLicenses = ( in_array(
$userDefaultLicense, $config['licensing']['ownWork']['licenses'] ) ||
+ $defaultInAllowedLicenses = ( in_array(
+ $userDefaultLicense,
$config['licensing']['ownWork']['licenses']
+ ) ||
in_array( $userDefaultLicense,
UploadWizardConfig::getThirdPartyLicenses() ) );
break;
}
@@ -295,7 +300,7 @@
}
$rtq = wfArrayToCgi( $values );
if ( $rtq && $rtq != '' ) {
- $returnstr .= '&returntoquery=' .
urlencode($rtq);
+ $returnstr .= '&returntoquery=' .
urlencode( $rtq );
}
$this->getOutput()->showErrorPage(
'uploadnologin', 'mwe-upwiz-error-nologin', $returnstr );
} else {
@@ -334,7 +339,9 @@
$config = UploadWizardConfig::getConfig( $this->campaign );
- if ( array_key_exists( 'display', $config ) &&
array_key_exists( 'headerLabel', $config['display'] ) ) {
+ if ( array_key_exists(
+ 'display', $config ) && array_key_exists(
'headerLabel', $config['display'] )
+ ) {
$this->getOutput()->addHtml(
$config['display']['headerLabel'] );
}
@@ -367,13 +374,17 @@
$tutorialHtml = '';
// only load the tutorial HTML if we aren't skipping the first
step
- if ( !$this->getUser()->getBoolOption( 'upwiz_skiptutorial' )
&& $config['tutorial'] !== null && $config['tutorial'] !== array() &&
$config['tutorial']['skip'] !== true ) {
+ if ( !$this->getUser()->getBoolOption( 'upwiz_skiptutorial' ) &&
+ $config['tutorial'] !== null && $config['tutorial'] !==
array() &&
+ $config['tutorial']['skip'] !== true
+ ) {
$tutorialHtml = UploadWizardTutorial::getHtml(
$this->campaign );
}
// TODO move this into UploadWizard.js or some other javascript
resource so the upload wizard
// can be dynamically included ( for example the add media
wizard )
return
+ // @codingStandardsIgnoreStart
'<div id="upload-wizard" class="upload-section">' .
// if loading takes > 2 seconds display
spinner. Note we are evading Resource Loader here, and linking directly.
Because we want an image to appear if RL's package is late.
@@ -459,6 +470,7 @@
'<div class="mwe-upwiz-clearing"></div>' .
'</div>';
+ // @codingStandardsIgnoreEnd
}
protected function getGroupName() {
@@ -473,10 +485,11 @@
class UploadWizardSimpleForm extends UploadForm {
/*
- * Normally, UploadForm adds its own Javascript.
- * We wish to prevent this, because we want to control the case where
we have Javascript.
- * So, we make the addUploadJS a no-op.
+ * Normally, UploadForm adds its own Javascript.
+ * We wish to prevent this, because we want to control the case where
we have Javascript.
+ * So, we make the addUploadJS a no-op.
*/
- protected function addUploadJS( ) { }
+ protected function addUploadJS() {
+ }
}
diff --git a/languageStats.php b/languageStats.php
index d3a6ff9..c881410 100644
--- a/languageStats.php
+++ b/languageStats.php
@@ -1,7 +1,5 @@
<?php
-require( 'UploadWizard.i18n.php' );
-
$langsToTest = array_slice( $argv, 1 );
$wikipediaSize = getWikipediaSize();
@@ -9,14 +7,14 @@
$total = count( $messages['en'] );
foreach ( $wikipediaSize as $lang => $size ) {
- if ( count($langsToTest) and (! in_array( $lang, $langsToTest ) ) ) {
+ if ( count( $langsToTest ) and ( ! in_array( $lang, $langsToTest ) ) ) {
continue;
}
$percentComplete[$lang] = 0;
$translated = 0;
if ( array_key_exists( $lang, $messages ) ) {
$langDict = $messages[$lang];
- foreach( $messages['en'] as $key => $val ) {
+ foreach ( $messages['en'] as $key => $val ) {
if ( array_key_exists( $key, $langDict ) ) {
$translated++;
}
@@ -27,9 +25,10 @@
}
-
# taken from stats.wikimedia.org/EN/TablesArticlesTotal.htm May 2011
+// @codingStandardsIgnoreStart
function getWikipediaSize() {
+// @codingStandardsIgnoreEnd
return array(
'en' => 3600000,
'de' => 1200000,
diff --git a/maintenance/migrateCampaigns.php b/maintenance/migrateCampaigns.php
index debdcc4..02b6ee1 100644
--- a/maintenance/migrateCampaigns.php
+++ b/maintenance/migrateCampaigns.php
@@ -214,7 +214,10 @@
'defaultType' =>
$oldConfig['defaultLicenseType'],
'ownWorkDefault' => $oldConfig['ownWorkOption'],
'ownWork' => array(
- 'licenses' =>
$this->ensureDefaultLicense( $this->explodeStringToArray(
$oldConfig['licensesOwnWork'] ), $oldConfig['defaultOwnWorkLicense'] )
+ 'licenses' =>
$this->ensureDefaultLicense(
+ $this->explodeStringToArray(
$oldConfig['licensesOwnWork'] ),
+
$oldConfig['defaultOwnWorkLicense']
+ )
)
),
'fields' => array(
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="utf8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+</ruleset>
diff --git a/tests/phpunit/ApiFlickrBlacklistTest.php
b/tests/phpunit/ApiFlickrBlacklistTest.php
index 205182d..b557bf1 100644
--- a/tests/phpunit/ApiFlickrBlacklistTest.php
+++ b/tests/phpunit/ApiFlickrBlacklistTest.php
@@ -73,7 +73,7 @@
public function testBlacklistMatchWithMultipleItems() {
$this->checkApiSetup();
$this->setFlickrBlacklistPage( self::BLACKLIST_PAGE );
- $this->editPage( self::BLACKLIST_PAGE, 'foo bar ' .
self::PASFAM_NSID . ' baz');
+ $this->editPage( self::BLACKLIST_PAGE, 'foo bar ' .
self::PASFAM_NSID . ' baz' );
list( $response, , ) = $this->doApiRequest( array(
'action' => 'flickrblacklist',
@@ -189,8 +189,16 @@
*/
protected function assertBlacklistMatch( $result, $message = '' ) {
$this->assertArrayHasKey( 'flickrblacklist', $result, $message
?: 'API result missing' );
- $this->assertArrayHasKey( 'result', $result['flickrblacklist'],
$message ?: 'API result missing' );
- $this->assertEquals( 'bad',
$result['flickrblacklist']['result'], $message ?: 'blacklist does not match' );
+ $this->assertArrayHasKey(
+ 'result',
+ $result['flickrblacklist'],
+ $message ?: 'API result missing'
+ );
+ $this->assertEquals(
+ 'bad',
+ $result['flickrblacklist']['result'],
+ $message ?: 'blacklist does not match'
+ );
}
/**
@@ -199,7 +207,15 @@
*/
protected function assertNotBlacklistMatch( $result, $message = '' ) {
$this->assertArrayHasKey( 'flickrblacklist', $result, $message
?: 'API result missing' );
- $this->assertArrayHasKey( 'result', $result['flickrblacklist'],
$message ?: 'API result missing' );
- $this->assertEquals( 'ok',
$result['flickrblacklist']['result'], $message ?: 'blacklist does match' );
+ $this->assertArrayHasKey(
+ 'result',
+ $result['flickrblacklist'],
+ $message ?: 'API result missing'
+ );
+ $this->assertEquals(
+ 'ok',
+ $result['flickrblacklist']['result'],
+ $message ?: 'blacklist does match'
+ );
}
}
diff --git a/tests/phpunit/UploadWizardConfigTest.php
b/tests/phpunit/UploadWizardConfigTest.php
index e59ddc5..d46f38c 100644
--- a/tests/phpunit/UploadWizardConfigTest.php
+++ b/tests/phpunit/UploadWizardConfigTest.php
@@ -35,7 +35,9 @@
/**
* @dataProvider objRefProvider
*/
- public function
testButtonTargetIsSetToUseObjRef_buttonHrefMatchesRefPage( $objRef,
$expectedResult ) {
+ public function
testButtonTargetIsSetToUseObjRef_buttonHrefMatchesRefPage(
+ $objRef, $expectedResult
+ ) {
global $wgUploadWizardConfig;
ParserTest::setupInterwikis();
@@ -65,6 +67,8 @@
);
$config = $campaign->getParsedConfig();
- return isset( $config['display']['homeButton']['target'] ) ?
$config['display']['homeButton']['target'] : false;
+ return isset(
+ $config['display']['homeButton']['target']
+ ) ? $config['display']['homeButton']['target'] : false;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/242918
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8ce507668e81e324d2453e2f1d98bdc297deaa99
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits