Umherirrender has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/358064 )
Change subject: Make phpcs pass - cli ...................................................................... Make phpcs pass - cli Change-Id: I145da93bcb92b2f2aed9c24bfe9fa33ae8738e28 --- M cli/cli.inc M cli/convertVotes.php M cli/delete.php M cli/dump.php M cli/dumpComments.php M cli/dumpVoteCsv.php M cli/import.php M cli/makeSimpleList.php M cli/purgePrivateVoteData.php M cli/tally.php M cli/testDebian.php M cli/voterList.php M cli/wm-scripts/bv2013/buildSpamTranslations.php M cli/wm-scripts/bv2013/doSpam.php M cli/wm-scripts/bv2013/dumpMetaTranslations.php M cli/wm-scripts/bv2013/populateEditCount.php M cli/wm-scripts/bv2013/sendMails.php M cli/wm-scripts/bv2013/voterList.php M cli/wm-scripts/bv2015/doSpam.php M cli/wm-scripts/bv2015/populateEditCount-fixup.php M cli/wm-scripts/bv2015/populateEditCount.php M cli/wm-scripts/bv2015/voterList.php M cli/wm-scripts/bv2017/doSpam.php M cli/wm-scripts/bv2017/populateEditCount.php M cli/wm-scripts/bv2017/voterList.php M cli/wm-scripts/dumpGlobalVoterList.php 26 files changed, 42 insertions(+), 65 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll refs/changes/64/358064/1 diff --git a/cli/cli.inc b/cli/cli.inc index ea3d7f9..3b112bb 100644 --- a/cli/cli.inc +++ b/cli/cli.inc @@ -13,4 +13,4 @@ exit( 1 ); } -require( $IP . '/maintenance/commandLine.inc' ); +require $IP . '/maintenance/commandLine.inc'; diff --git a/cli/convertVotes.php b/cli/convertVotes.php index 6727dac..ed9c385 100644 --- a/cli/convertVotes.php +++ b/cli/convertVotes.php @@ -1,6 +1,6 @@ <?php -require( __DIR__.'/cli.inc' ); +require __DIR__ . '/cli.inc'; $usage = <<<EOT Usage: @@ -11,7 +11,6 @@ --no-proof-protection Disable protection for proof of vote (vote buying) EOT; - if ( !isset( $options['name'] ) && !isset( $args[0] ) ) { spFatal( $usage ); } @@ -20,7 +19,7 @@ if ( isset( $options['name'] ) ) { spFatal( "Cannot load from database when SecurePoll is not installed" ); } - require( __DIR__ . '/../SecurePoll.php' ); + require __DIR__ . '/../SecurePoll.php'; } $conv = new SecurePoll_ConvertVotes; @@ -30,7 +29,6 @@ } else { $conv->convertLocalElection( $options['name'] ); } - class SecurePoll_ConvertVotes { public $context, $election; diff --git a/cli/delete.php b/cli/delete.php index d0d26d2..17443ed 100644 --- a/cli/delete.php +++ b/cli/delete.php @@ -1,6 +1,6 @@ <?php -require( __DIR__ . '/cli.inc' ); +require __DIR__ . '/cli.inc'; $usage = <<<EOT Delete a poll from the local SecurePoll database. diff --git a/cli/dump.php b/cli/dump.php index 6f1df13..5a2ae05 100644 --- a/cli/dump.php +++ b/cli/dump.php @@ -4,9 +4,8 @@ * Generate an XML dump of an election, including configuration and votes. */ - $optionsWithArgs = array( 'o' ); -require( __DIR__.'/cli.inc' ); +require __DIR__ . '/cli.inc'; $usage = <<<EOT Usage: php dump.php [options...] <election name> @@ -82,4 +81,3 @@ } fwrite( $election->cbdata['outFile'], "<vote>" . $row->vote_record . "</vote>\n" ); } - diff --git a/cli/dumpComments.php b/cli/dumpComments.php index 71d5270..1ff5999 100644 --- a/cli/dumpComments.php +++ b/cli/dumpComments.php @@ -11,7 +11,7 @@ */ $optionsWithArgs = array( 'name' ); -require( __DIR__.'/cli.inc' ); +require __DIR__ . '/cli.inc'; $wgTitle = Title::newFromText( 'Special:SecurePoll' ); @@ -29,7 +29,7 @@ if ( isset( $options['name'] ) ) { spFatal( "Cannot load from database when SecurePoll is not installed" ); } - require( __DIR__ . '/../SecurePoll.php' ); + require __DIR__ . '/../SecurePoll.php'; } $context = new SecurePoll_Context; @@ -55,13 +55,12 @@ if ( !$status->isOK() ) { spFatal( "Tally error: " . $status->getWikiText() ); } -//$tallier = $status->value; +// $tallier = $status->value; if ( isset( $options['html'] ) ) { echo $tallier->getHtmlResult(); } else { echo $tallier->getTextResult(); } - function spFatal( $message ) { fwrite( STDERR, rtrim( $message ) . "\n" ); diff --git a/cli/dumpVoteCsv.php b/cli/dumpVoteCsv.php index 14d7fe2..d019227 100644 --- a/cli/dumpVoteCsv.php +++ b/cli/dumpVoteCsv.php @@ -11,7 +11,7 @@ */ $optionsWithArgs = array( 'name' ); -require( __DIR__.'/cli.inc' ); +require __DIR__ . '/cli.inc'; $wgTitle = Title::newFromText( 'Special:SecurePoll' ); @@ -29,7 +29,7 @@ if ( isset( $options['name'] ) ) { spFatal( "Cannot load from database when SecurePoll is not installed" ); } - require( __DIR__ . '/../SecurePoll.php' ); + require __DIR__ . '/../SecurePoll.php'; } $context = new SecurePoll_Context; @@ -55,13 +55,12 @@ if ( !$status->isOK() ) { spFatal( "Tally error: " . $status->getWikiText() ); } -//$tallier = $status->value; +// $tallier = $status->value; if ( isset( $options['html'] ) ) { echo $tallier->getHtmlResult(); } else { echo $tallier->getTextResult(); } - function spFatal( $message ) { fwrite( STDERR, rtrim( $message ) . "\n" ); diff --git a/cli/import.php b/cli/import.php index 92ba7ec..20470c5 100644 --- a/cli/import.php +++ b/cli/import.php @@ -1,6 +1,6 @@ <?php -require( __DIR__ . '/cli.inc' ); +require __DIR__ . '/cli.inc'; $usage = <<<EOT Import configuration files into the local SecurePoll database. Files can be @@ -288,4 +288,3 @@ spInsertMessages( $store, $entityIds ); return true; } - diff --git a/cli/makeSimpleList.php b/cli/makeSimpleList.php index f63f477..8513e8f 100644 --- a/cli/makeSimpleList.php +++ b/cli/makeSimpleList.php @@ -14,7 +14,7 @@ */ $optionsWithArgs = array( 'before', 'edits', 'start-from' ); -require( __DIR__ . '/cli.inc' ); +require __DIR__ . '/cli.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); diff --git a/cli/purgePrivateVoteData.php b/cli/purgePrivateVoteData.php index a8292b4..b46a4a3 100644 --- a/cli/purgePrivateVoteData.php +++ b/cli/purgePrivateVoteData.php @@ -24,13 +24,12 @@ * @ingroup Maintenance */ - if ( getenv( 'MW_INSTALL_PATH' ) ) { $IP = getenv( 'MW_INSTALL_PATH' ); } else { $IP = __DIR__ . '/../../..'; } -require_once( "$IP/maintenance/Maintenance.php" ); +require_once "$IP/maintenance/Maintenance.php"; class PurgePrivateVoteData extends Maintenance { @@ -66,7 +65,7 @@ __METHOD__ ); - foreach ( $elResult as $row ) { + foreach ( $elResult as $row ) { $electionsToPurge[] = $row->el_entity; $this->output( "Election '{$row->el_title}' with end date '{$row->el_end_date}' " . "will have data purged\n" ); @@ -92,7 +91,7 @@ $setMin = null; $setMax = null; - foreach ( $vRes as $row ) { + foreach ( $vRes as $row ) { if ( $setMin === null ) { $setMin = $row->vote_id; } @@ -100,7 +99,7 @@ } $deleteSets[] = array( $setMin, $setMax ); $minVoteId = $setMax; - } while( $vRes->numRows() == $this->mBatchSize ); + } while ( $vRes->numRows() == $this->mBatchSize ); $dbw = wfGetDB( DB_MASTER ); @@ -126,4 +125,4 @@ } $maintClass = "PurgePrivateVoteData"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/cli/tally.php b/cli/tally.php index f44c475..4bdf91e 100644 --- a/cli/tally.php +++ b/cli/tally.php @@ -8,7 +8,7 @@ */ $optionsWithArgs = array( 'name' ); -require( __DIR__.'/cli.inc' ); +require __DIR__ . '/cli.inc'; $wgTitle = Title::newFromText( 'Special:SecurePoll' ); @@ -26,7 +26,7 @@ if ( isset( $options['name'] ) ) { spFatal( "Cannot load from database when SecurePoll is not installed" ); } - require( __DIR__ . '/../SecurePoll.php' ); + require __DIR__ . '/../SecurePoll.php'; } $context = new SecurePoll_Context; @@ -56,7 +56,6 @@ } else { echo $tallier->getTextResult(); } - function spFatal( $message ) { fwrite( STDERR, rtrim( $message ) . "\n" ); diff --git a/cli/testDebian.php b/cli/testDebian.php index 434677c..cd2f17e 100644 --- a/cli/testDebian.php +++ b/cli/testDebian.php @@ -1,7 +1,7 @@ <?php -require( __DIR__.'/cli.inc' ); -$testDir = __DIR__.'/debtest'; +require __DIR__ . '/cli.inc'; +$testDir = __DIR__ . '/debtest'; if ( !is_dir( $testDir ) ) { mkdir( $testDir ); } @@ -55,7 +55,7 @@ } $record = array(); - for ( $i = 0; $i < strlen( $m[1] ); $i++ ) { + for ( $i = 0, $len = strlen( $m[1] ); $i < $len; $i++ ) { $pref = substr( $m[1], $i, 1 ); if ( $i == strlen( $m[1] ) - 1 ) { $id = 'X'; @@ -172,4 +172,3 @@ return $this->id; } } - diff --git a/cli/voterList.php b/cli/voterList.php index 7a23d02..fd4f941 100644 --- a/cli/voterList.php +++ b/cli/voterList.php @@ -8,7 +8,7 @@ } $optionsWithArgs = array( 'before', 'edits' ); -require( $IP . '/maintenance/commandLine.inc' ); +require $IP . '/maintenance/commandLine.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); diff --git a/cli/wm-scripts/bv2013/buildSpamTranslations.php b/cli/wm-scripts/bv2013/buildSpamTranslations.php index f747c80..91cb0bb 100644 --- a/cli/wm-scripts/bv2013/buildSpamTranslations.php +++ b/cli/wm-scripts/bv2013/buildSpamTranslations.php @@ -4,7 +4,7 @@ if ( $IP === false ) { $IP = __DIR__ . '/../../../../..'; } -require_once( "$IP/maintenance/commandLine.inc" ); +require_once "$IP/maintenance/commandLine.inc"; $wgDebugLogFile = '/dev/stderr'; @@ -22,7 +22,7 @@ 'boardelection-spam-translation' ); -foreach( $res as $row ) { +foreach ( $res as $row ) { $page = WikiPage::newFromID( $row->page_id ); print "Got article " . $row->page_id . "\n"; diff --git a/cli/wm-scripts/bv2013/doSpam.php b/cli/wm-scripts/bv2013/doSpam.php index 1d161a0..1441422 100644 --- a/cli/wm-scripts/bv2013/doSpam.php +++ b/cli/wm-scripts/bv2013/doSpam.php @@ -4,7 +4,7 @@ if ( $IP === false ) { $IP = __DIR__ . '/../../../../..'; } -require_once( "$IP/maintenance/commandLine.inc" ); +require_once "$IP/maintenance/commandLine.inc"; ini_set( 'display_errors', 1 ); @@ -43,7 +43,7 @@ } $wikis = CentralAuthUser::getWikiList(); -#$wikis = array( 'frwiki', 'dewiki', 'commonswiki', 'usabilitywiki' ); +# $wikis = array( 'frwiki', 'dewiki', 'commonswiki', 'usabilitywiki' ); $wgConf->loadFullData(); $users = array(); diff --git a/cli/wm-scripts/bv2013/dumpMetaTranslations.php b/cli/wm-scripts/bv2013/dumpMetaTranslations.php index a2a3e0b..2a09846 100644 --- a/cli/wm-scripts/bv2013/dumpMetaTranslations.php +++ b/cli/wm-scripts/bv2013/dumpMetaTranslations.php @@ -1,6 +1,6 @@ <?php -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $spConf = array( 'numCandidates' => 18, @@ -86,7 +86,7 @@ $s = $header . spFormatEntityMessages( $allMessages, 'election' ) . "<question>\n" . - "<id>" . ($spConf['baseId'] + 1) . "</id>\n" . + "<id>" . ( $spConf['baseId'] + 1 ) . "</id>\n" . "<message name=\"text\" lang=\"en\"></message>\n"; for ( $i = 1; $i <= $spConf['numCandidates']; $i++ ) { @@ -104,7 +104,7 @@ echo $s; exit( 0 ); -//------------------------------------------------------------------ +// ------------------------------------------------------------------ /** * @param $lang string @@ -208,4 +208,3 @@ } return $s; } - diff --git a/cli/wm-scripts/bv2013/populateEditCount.php b/cli/wm-scripts/bv2013/populateEditCount.php index 8253d43..2cbcf20 100644 --- a/cli/wm-scripts/bv2013/populateEditCount.php +++ b/cli/wm-scripts/bv2013/populateEditCount.php @@ -6,7 +6,7 @@ * have made at least 20 edits between 15 December 2012 and 30 April 2013. */ -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); @@ -54,4 +54,3 @@ } echo wfWikiID() . ": $numUsers users added\n"; - diff --git a/cli/wm-scripts/bv2013/sendMails.php b/cli/wm-scripts/bv2013/sendMails.php index 2fe6c9f..caa1ad9 100644 --- a/cli/wm-scripts/bv2013/sendMails.php +++ b/cli/wm-scripts/bv2013/sendMails.php @@ -4,7 +4,7 @@ if ( $IP === false ) { $IP = __DIR__ . '/../../../../..'; } -require_once( "$IP/maintenance/commandLine.inc" ); +require_once "$IP/maintenance/commandLine.inc"; ini_set( 'display_errors', 1 ); $err = fopen( 'php://stderr', 'w' ); @@ -32,7 +32,9 @@ $transTemplates[$lang] = file_get_contents( $file ); } +// @codingStandardsIgnoreStart while ( !is_null( $line = fgets( $in ) ) ) { +// @codingStandardsIgnoreEnd if ( !$line ) { continue; } diff --git a/cli/wm-scripts/bv2013/voterList.php b/cli/wm-scripts/bv2013/voterList.php index c0ea526..153f808 100644 --- a/cli/wm-scripts/bv2013/voterList.php +++ b/cli/wm-scripts/bv2013/voterList.php @@ -1,6 +1,6 @@ <?php -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); $fname = 'voterList.php'; diff --git a/cli/wm-scripts/bv2015/doSpam.php b/cli/wm-scripts/bv2015/doSpam.php index ca055cf..d06ac08 100644 --- a/cli/wm-scripts/bv2015/doSpam.php +++ b/cli/wm-scripts/bv2015/doSpam.php @@ -65,13 +65,10 @@ return $lang; } - - $voted = array(); $vdb = wfGetDB( DB_SLAVE, array(), 'votewiki' ); $voted = $vdb->selectFieldValues( 'securepoll_voters', 'voter_name', array( 'voter_election' => $electionId ) ); - $db = CentralAuthUser::getCentralSlaveDB(); $res = $db->select( diff --git a/cli/wm-scripts/bv2015/populateEditCount-fixup.php b/cli/wm-scripts/bv2015/populateEditCount-fixup.php index 24c2eae..f0fdb5d 100644 --- a/cli/wm-scripts/bv2015/populateEditCount-fixup.php +++ b/cli/wm-scripts/bv2015/populateEditCount-fixup.php @@ -3,7 +3,7 @@ /** Fix for populateEditCount.php which used a cutoff date of * 20150401500000 instead of 20150415000000 for bv_long_edits */ -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); @@ -46,5 +46,3 @@ } echo wfWikiID() . ": $numUsers users added\n"; - - diff --git a/cli/wm-scripts/bv2015/populateEditCount.php b/cli/wm-scripts/bv2015/populateEditCount.php index d90bee5..5e23abf 100644 --- a/cli/wm-scripts/bv2015/populateEditCount.php +++ b/cli/wm-scripts/bv2015/populateEditCount.php @@ -6,7 +6,7 @@ * have made at least 20 edits between 15 October 2014 and 15 April 2015. */ -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); @@ -54,4 +54,3 @@ } echo wfWikiID() . ": $numUsers users added\n"; - diff --git a/cli/wm-scripts/bv2015/voterList.php b/cli/wm-scripts/bv2015/voterList.php index 3f90968..548c91a 100644 --- a/cli/wm-scripts/bv2015/voterList.php +++ b/cli/wm-scripts/bv2015/voterList.php @@ -1,6 +1,6 @@ <?php -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbcr = CentralAuthUser::getCentralSlaveDB(); $dbcw = CentralAuthUser::getCentralDB(); @@ -152,4 +152,3 @@ $lang->formatDuration( $estRemaining ) . "\n"; } - diff --git a/cli/wm-scripts/bv2017/doSpam.php b/cli/wm-scripts/bv2017/doSpam.php index ca055cf..d06ac08 100644 --- a/cli/wm-scripts/bv2017/doSpam.php +++ b/cli/wm-scripts/bv2017/doSpam.php @@ -65,13 +65,10 @@ return $lang; } - - $voted = array(); $vdb = wfGetDB( DB_SLAVE, array(), 'votewiki' ); $voted = $vdb->selectFieldValues( 'securepoll_voters', 'voter_name', array( 'voter_election' => $electionId ) ); - $db = CentralAuthUser::getCentralSlaveDB(); $res = $db->select( diff --git a/cli/wm-scripts/bv2017/populateEditCount.php b/cli/wm-scripts/bv2017/populateEditCount.php index a36b6f8..b763b7b 100644 --- a/cli/wm-scripts/bv2017/populateEditCount.php +++ b/cli/wm-scripts/bv2017/populateEditCount.php @@ -6,7 +6,7 @@ * have made at least 20 edits between 01 October 2016 and 01 April 2017. */ -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); @@ -54,4 +54,3 @@ } echo wfWikiID() . ": $numUsers users added\n"; - diff --git a/cli/wm-scripts/bv2017/voterList.php b/cli/wm-scripts/bv2017/voterList.php index 7abffac..9def81e 100644 --- a/cli/wm-scripts/bv2017/voterList.php +++ b/cli/wm-scripts/bv2017/voterList.php @@ -1,6 +1,6 @@ <?php -require( __DIR__ . '/../../cli.inc' ); +require __DIR__ . '/../../cli.inc'; $dbcr = CentralAuthUser::getCentralSlaveDB(); $dbcw = CentralAuthUser::getCentralDB(); @@ -152,4 +152,3 @@ $lang->formatDuration( $estRemaining ) . "\n"; } - diff --git a/cli/wm-scripts/dumpGlobalVoterList.php b/cli/wm-scripts/dumpGlobalVoterList.php index 8606911..ea592ff 100644 --- a/cli/wm-scripts/dumpGlobalVoterList.php +++ b/cli/wm-scripts/dumpGlobalVoterList.php @@ -1,6 +1,6 @@ <?php -require( __DIR__.'/../cli.inc' ); +require __DIR__.'/../cli.inc'; $voters = array(); $batchSize = 1000; @@ -53,4 +53,3 @@ foreach ( $voters as $email => $info ) { echo "{$info['name']} <$email>\n"; } - -- To view, visit https://gerrit.wikimedia.org/r/358064 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I145da93bcb92b2f2aed9c24bfe9fa33ae8738e28 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SecurePoll Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits