jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358073 )
Change subject: Use short array syntax - includes/pages ...................................................................... Use short array syntax - includes/pages Done by phpcbf over composer fix Change-Id: I17aa9005f8b2cf4fcd8c2455dc0000b9b3c017c1 --- M includes/pages/ActionPage.php M includes/pages/CreatePage.php M includes/pages/DetailsPage.php M includes/pages/DumpPage.php M includes/pages/EntryPage.php M includes/pages/ListPage.php M includes/pages/MessageDumpPage.php M includes/pages/TallyPage.php M includes/pages/TranslatePage.php M includes/pages/VotePage.php M includes/pages/VoterEligibilityPage.php 11 files changed, 444 insertions(+), 444 deletions(-) Approvals: Huji: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/includes/pages/ActionPage.php b/includes/pages/ActionPage.php index 5cf05b0..a7227dd 100644 --- a/includes/pages/ActionPage.php +++ b/includes/pages/ActionPage.php @@ -45,7 +45,7 @@ } $languages = array_merge( - array( $userLang ), + [ $userLang ], Language::getFallbacksFor( $userLang ) ); if ( !in_array( $election->getLanguage(), $languages ) ) { @@ -61,6 +61,6 @@ * Relay for SpecialPage::msg */ protected function msg( /* args */ ) { - return call_user_func_array( array( $this->specialPage, 'msg' ), func_get_args() ); + return call_user_func_array( [ $this->specialPage, 'msg' ], func_get_args() ); } } diff --git a/includes/pages/CreatePage.php b/includes/pages/CreatePage.php index d7b638c..2e44e02 100644 --- a/includes/pages/CreatePage.php +++ b/includes/pages/CreatePage.php @@ -66,38 +66,38 @@ # These are for injecting raw HTML into the HTMLForm for the # multi-column aspects of the designed layout. - $layoutTableStart = array( + $layoutTableStart = [ 'type' => 'info', 'rawrow' => true, 'default' => '<table class="securepoll-layout-table"><tr><td>', - ); - $layoutTableMid = array( + ]; + $layoutTableMid = [ 'type' => 'info', 'rawrow' => true, 'default' => '</td><td>', - ); - $layoutTableEnd = array( + ]; + $layoutTableEnd = [ 'type' => 'info', 'rawrow' => true, 'default' => '</td></tr></table>', - ); + ]; - $formItems = array(); + $formItems = []; - $formItems['election_id'] = array( + $formItems['election_id'] = [ 'type' => 'hidden', 'default' => -1, 'output-as-default' => false, - ); + ]; - $formItems['election_title'] = array( + $formItems['election_title'] = [ 'label-message' => 'securepoll-create-label-election_title', 'type' => 'text', 'required' => true, - ); + ]; $wikiNames = SecurePoll_FormStore::getWikiList(); - $options = array(); + $options = []; $options['securepoll-create-option-wiki-this_wiki'] = wfWikiID(); if ( count( $wikiNames ) > 1 ) { $options['securepoll-create-option-wiki-all_wikis'] = '*'; @@ -112,7 +112,7 @@ // Only option is wfWikiID(), so don't bother making the user select it. } elseif ( count( $wikiNames ) < 10 ) { // So few, we may as well just list them explicitly - $opts = array(); + $opts = []; foreach ( $options as $msg => $value ) { $opts[$this->msg( $msg )->plain()] = $value; } @@ -124,165 +124,165 @@ $opts[$this->msg( 'securepoll-create-option-wiki-other_wiki' )->plain()] = $wikiNames; } - $formItems['property_wiki'] = array( + $formItems['property_wiki'] = [ 'type' => 'select', 'options' => $opts, 'label-message' => 'securepoll-create-label-wiki', - ); + ]; } else { $options['securepoll-create-option-wiki-other_wiki'] = 'other'; - $formItems['property_wiki'] = array( + $formItems['property_wiki'] = [ 'type' => 'autocompleteselect', 'autocomplete-data' => $wikiNames, 'options-messages' => $options, 'label-message' => 'securepoll-create-label-wiki', 'require-match' => true, 'default' => wfWikiID(), - ); + ]; } $languages = Language::fetchLanguageNames( null, 'mw' ); ksort( $languages ); - $options = array(); + $options = []; foreach ( $languages as $code => $name ) { $display = wfBCP47( $code ) . ' - ' . $name; $options[$display] = $code; } - $formItems['election_primaryLang'] = array( + $formItems['election_primaryLang'] = [ 'type' => 'select', 'options' => $options, 'label-message' => 'securepoll-create-label-election_primaryLang', 'default' => 'en', 'required' => true, - ); + ]; - $formItems['election_startdate'] = array( + $formItems['election_startdate'] = [ 'label-message' => 'securepoll-create-label-election_startdate', 'type' => 'date', 'required' => true, 'min' => gmdate( 'M-d-Y' ), - ); + ]; - $days = array(); + $days = []; for ( $i = 1; $i <= 28; $i++ ) { $days[$i] = $i; } - $formItems['election_duration'] = array( + $formItems['election_duration'] = [ 'type' => 'select', 'label-message' => 'securepoll-create-label-election_duration', 'required' => true, 'options' => $days, - ); + ]; - $formItems['return-url'] = array( + $formItems['return-url'] = [ 'label-message' => 'securepoll-create-label-election_return-url', 'type' => 'url', - ); + ]; if ( isset( $formItems['property_wiki'] ) ) { - $formItems['jump-text'] = array( + $formItems['jump-text'] = [ 'label-message' => 'securepoll-create-label-election_jump-text', 'type' => 'text', - ); + ]; if ( $formItems['property_wiki']['type'] === 'select' ) { - $formItems['jump-text']['hide-if'] = array( '===', 'property_wiki', wfWikiId() ); + $formItems['jump-text']['hide-if'] = [ '===', 'property_wiki', wfWikiId() ]; } else { - $formItems['jump-text']['hide-if'] = array( '===', 'property_wiki-select', wfWikiId() ); + $formItems['jump-text']['hide-if'] = [ '===', 'property_wiki-select', wfWikiId() ]; } } $formItems[] = $layoutTableStart; - $formItems['election_type'] = array( + $formItems['election_type'] = [ 'label-message' => 'securepoll-create-label-election_type', 'type' => 'radio', - 'options-messages' => array(), + 'options-messages' => [], 'required' => true, - ); + ]; if ( count( SecurePoll_Crypt::$cryptTypes ) > 1 ) { $formItems[] = $layoutTableMid; - $formItems['election_crypt'] = array( + $formItems['election_crypt'] = [ 'label-message' => 'securepoll-create-label-election_crypt', 'type' => 'radio', - 'options-messages' => array(), + 'options-messages' => [], 'required' => true, - ); + ]; } else { reset( SecurePoll_Crypt::$cryptTypes ); - $formItems['election_crypt'] = array( + $formItems['election_crypt'] = [ 'type' => 'hidden', 'default' => key( SecurePoll_Crypt::$cryptTypes ), - 'options-messages' => array(), // dummy, ignored - ); + 'options-messages' => [], // dummy, ignored + ]; } $formItems[] = $layoutTableEnd; - $formItems['disallow-change'] = array( + $formItems['disallow-change'] = [ 'label-message' => 'securepoll-create-label-election_disallow-change', 'type' => 'check', 'hidelabel' => true, - ); + ]; - $formItems['voter-privacy'] = array( + $formItems['voter-privacy'] = [ 'label-message' => 'securepoll-create-label-voter_privacy', 'type' => 'check', 'hidelabel' => true, - ); + ]; - $formItems['property_admins'] = array( + $formItems['property_admins'] = [ 'label-message' => 'securepoll-create-label-property_admins', 'type' => 'cloner', 'required' => true, 'format' => 'raw', - 'fields' => array( - 'username' => array( + 'fields' => [ + 'username' => [ 'type' => 'text', 'required' => true, - 'validation-callback' => array( $this, 'checkUsername' ), - ), - ), - ); + 'validation-callback' => [ $this, 'checkUsername' ], + ], + ], + ]; - $questionFields = array( - 'id' => array( + $questionFields = [ + 'id' => [ 'type' => 'hidden', 'default' => -1, 'output-as-default' => false, - ), - 'text' => array( + ], + 'text' => [ 'label-message' => 'securepoll-create-label-questions-question', 'type' => 'text', 'required' => true, - ), - 'delete' => array( + ], + 'delete' => [ 'type' => 'submit', 'default' => $this->msg( 'securepoll-create-label-questions-delete' )->text(), - ), - ); + ], + ]; - $optionFields = array( - 'id' => array( + $optionFields = [ + 'id' => [ 'type' => 'hidden', 'default' => -1, 'output-as-default' => false, - ), - 'text' => array( + ], + 'text' => [ 'label-message' => 'securepoll-create-label-options-option', 'type' => 'text', 'required' => true, - ), - 'delete' => array( + ], + 'delete' => [ 'type' => 'submit', 'default' => $this->msg( 'securepoll-create-label-options-delete' )->text(), - ), - ); + ], + ]; - $tallyTypes = array(); + $tallyTypes = []; foreach ( SecurePoll_Ballot::$ballotTypes as $ballotType => $ballotClass ) { - $types = array(); - foreach ( call_user_func_array( array( $ballotClass, 'getTallyTypes' ), array() ) + $types = []; + foreach ( call_user_func_array( [ $ballotClass, 'getTallyTypes' ], [] ) as $tallyType ) { $type = "$ballotType+$tallyType"; @@ -333,29 +333,29 @@ } } - $questionFields['options'] = array( + $questionFields['options'] = [ 'label-message' => 'securepoll-create-label-questions-option', 'type' => 'cloner', 'required' => true, 'create-button-message' => 'securepoll-create-label-options-add', 'fields' => $optionFields, - ); + ]; - $formItems['questions'] = array( + $formItems['questions'] = [ 'label-message' => 'securepoll-create-label-questions', 'type' => 'cloner', 'required' => true, 'row-legend' => 'securepoll-create-questions-row-legend', 'create-button-message' => 'securepoll-create-label-questions-add', 'fields' => $questionFields, - ); + ]; if ( $wgSecurePollUseNamespace ) { - $formItems['comment'] = array( + $formItems['comment'] = [ 'type' => 'text', 'label-message' => 'securepoll-create-label-comment', 'maxlength' => 250, - ); + ]; } $form = HTMLForm::factory( 'div', $formItems, $this->specialPage->getContext(), @@ -365,7 +365,7 @@ $form->setSubmitTextMsg( $this->election ? 'securepoll-edit-action' : 'securepoll-create-action' ); - $form->setSubmitCallback( array( $this, 'processInput' ) ); + $form->setSubmitCallback( [ $this, 'processInput' ] ); $form->prepareForm(); // If this isn't the result of a POST, load the data from the election @@ -427,24 +427,24 @@ if ( $store->rId ) { foreach ( $store->remoteWikis as $dbname ) { $lb = wfGetLB( $dbname ); - $rdbw = $lb->getConnection( DB_MASTER, array(), $dbname ); + $rdbw = $lb->getConnection( DB_MASTER, [], $dbname ); // Find an existing dummy election, if any $rId = $rdbw->selectField( - array( 'p1' => 'securepoll_properties', 'p2' => 'securepoll_properties' ), + [ 'p1' => 'securepoll_properties', 'p2' => 'securepoll_properties' ], 'p1.pr_entity', - array( + [ 'p1.pr_entity = p2.pr_entity', 'p1.pr_key' => 'jump-id', 'p1.pr_value' => $election->getId(), 'p2.pr_key' => 'main-wiki', 'p2.pr_value' => wfWikiID(), - ) + ] ); // Test for duplicate title - $id = $rdbw->selectField( 'securepoll_elections', 'el_entity', array( + $id = $rdbw->selectField( 'securepoll_elections', 'el_entity', [ 'el_title' => $formData['election_title'] - ) ); + ] ); $lb->reuseConnection( $rdbw ); @@ -462,9 +462,9 @@ // Ok, begin the actual work $dbw->startAtomic( __METHOD__ ); if ( $election->getId() > 0 ) { - $id = $dbw->selectField( 'securepoll_elections', 'el_entity', array( + $id = $dbw->selectField( 'securepoll_elections', 'el_entity', [ 'el_entity' => $election->getId() - ), __METHOD__, array( 'FOR UPDATE' ) ); + ], __METHOD__, [ 'FOR UPDATE' ] ); if ( !$id ) { $dbw->endAtomic( __METHOD__ ); return Status::newFatal( 'securepoll-create-fail-id-missing' ); @@ -472,7 +472,7 @@ } // Insert or update the election entity - $fields = array( + $fields = [ 'el_title' => $election->title, 'el_ballot' => $election->ballotType, 'el_tally' => $election->tallyType, @@ -481,26 +481,26 @@ 'el_end_date' => $dbw->timestamp( $election->getEndDate() ), 'el_auth_type' => $election->authType, 'el_owner' => $election->owner, - ); + ]; if ( $election->getId() < 0 ) { $eId = self::insertEntity( $dbw, 'election' ); - $qIds = array(); - $oIds = array(); + $qIds = []; + $oIds = []; $fields['el_entity'] = $eId; $dbw->insert( 'securepoll_elections', $fields, __METHOD__ ); } else { $eId = $election->getId(); - $dbw->update( 'securepoll_elections', $fields, array( 'el_entity' => $eId ), __METHOD__ ); + $dbw->update( 'securepoll_elections', $fields, [ 'el_entity' => $eId ], __METHOD__ ); // Delete any questions or options that weren't included in the // form submission. - $qIds = array(); - $res = $dbw->select( 'securepoll_questions', 'qu_entity', array( 'qu_election' => $eId ) ); + $qIds = []; + $res = $dbw->select( 'securepoll_questions', 'qu_entity', [ 'qu_election' => $eId ] ); foreach ( $res as $row ) { $qIds[] = $row->qu_entity; } - $oIds = array(); - $res = $dbw->select( 'securepoll_options', 'op_entity', array( 'op_election' => $eId ) ); + $oIds = []; + $res = $dbw->select( 'securepoll_options', 'op_entity', [ 'op_election' => $eId ] ); foreach ( $res as $row ) { $oIds[] = $row->op_entity; } @@ -509,11 +509,11 @@ array_diff( $oIds, $store->oIds ) ); if ( $deleteIds ) { - $dbw->delete( 'securepoll_msgs', array( 'msg_entity' => $deleteIds ), __METHOD__ ); - $dbw->delete( 'securepoll_properties', array( 'pr_entity' => $deleteIds ), __METHOD__ ); - $dbw->delete( 'securepoll_questions', array( 'qu_entity' => $deleteIds ), __METHOD__ ); - $dbw->delete( 'securepoll_options', array( 'op_entity' => $deleteIds ), __METHOD__ ); - $dbw->delete( 'securepoll_entity', array( 'en_id' => $deleteIds ), __METHOD__ ); + $dbw->delete( 'securepoll_msgs', [ 'msg_entity' => $deleteIds ], __METHOD__ ); + $dbw->delete( 'securepoll_properties', [ 'pr_entity' => $deleteIds ], __METHOD__ ); + $dbw->delete( 'securepoll_questions', [ 'qu_entity' => $deleteIds ], __METHOD__ ); + $dbw->delete( 'securepoll_options', [ 'op_entity' => $deleteIds ], __METHOD__ ); + $dbw->delete( 'securepoll_entity', [ 'en_id' => $deleteIds ], __METHOD__ ); } } self::savePropertiesAndMessages( $dbw, $eId, $election ); @@ -526,12 +526,12 @@ $qId = self::insertEntity( $dbw, 'question' ); } $dbw->replace( 'securepoll_questions', - array( 'qu_entity' ), - array( + [ 'qu_entity' ], + [ 'qu_entity' => $qId, 'qu_election' => $eId, 'qu_index' => ++$qIndex, - ), + ], __METHOD__ ); self::savePropertiesAndMessages( $dbw, $qId, $question ); @@ -542,12 +542,12 @@ $oId = self::insertEntity( $dbw, 'option' ); } $dbw->replace( 'securepoll_options', - array( 'op_entity' ), - array( + [ 'op_entity' ], + [ 'op_entity' => $oId, 'op_election' => $eId, 'op_question' => $qId, - ), + ], __METHOD__ ); self::savePropertiesAndMessages( $dbw, $oId, $option ); @@ -560,19 +560,19 @@ $election = $context->getElection( $store->rId ); foreach ( $store->remoteWikis as $dbname ) { $lb = wfGetLB( $dbname ); - $dbw = $lb->getConnection( DB_MASTER, array(), $dbname ); + $dbw = $lb->getConnection( DB_MASTER, [], $dbname ); $dbw->startAtomic( __METHOD__ ); // Find an existing dummy election, if any $rId = $dbw->selectField( - array( 'p1' => 'securepoll_properties', 'p2' => 'securepoll_properties' ), + [ 'p1' => 'securepoll_properties', 'p2' => 'securepoll_properties' ], 'p1.pr_entity', - array( + [ 'p1.pr_entity = p2.pr_entity', 'p1.pr_key' => 'jump-id', 'p1.pr_value' => $eId, 'p2.pr_key' => 'main-wiki', 'p2.pr_value' => wfWikiID(), - ) + ] ); if ( !$rId ) { $rId = self::insertEntity( $dbw, 'election' ); @@ -580,8 +580,8 @@ // Insert it! We don't have to care about questions or options here. $dbw->replace( 'securepoll_elections', - array( 'el_entity' ), - array( + [ 'el_entity' ], + [ 'el_entity' => $rId, 'el_title' => $election->title, 'el_ballot' => $election->ballotType, @@ -590,15 +590,15 @@ 'el_start_date' => $dbw->timestamp( $election->getStartDate() ), 'el_end_date' => $dbw->timestamp( $election->getEndDate() ), 'el_auth_type' => $election->authType, - ), + ], __METHOD__ ); self::savePropertiesAndMessages( $dbw, $rId, $election ); // Fix jump-id $dbw->update( 'securepoll_properties', - array( 'pr_value' => $eId ), - array( 'pr_entity' => $rId, 'pr_key' => 'jump-id' ), + [ 'pr_value' => $eId ], + [ 'pr_entity' => $rId, 'pr_key' => 'jump-id' ], __METHOD__ ); $dbw->endAtomic( __METHOD__ ); @@ -650,7 +650,7 @@ $tally = $data['tally']; $crypt = isset( $p['encrypt-type'] ) ? $p['encrypt-type'] : 'none'; - $formData = array( + $formData = [ 'election_id' => $data['id'], 'election_title' => $data['title'], 'property_wiki' => isset( $p['wikis-val'] ) ? $p['wikis-val'] : null, @@ -665,22 +665,22 @@ ? (bool)$p['disallow-change'] : null, 'voter-privacy' => isset( $p['voter-privacy'] ) ? (bool)$p['voter-privacy'] : null, - 'property_admins' => array(), - 'questions' => array(), + 'property_admins' => [], + 'questions' => [], 'comment' => '', - ); + ]; if ( isset( $data['properties']['admins'] ) ) { foreach ( explode( '|', $data['properties']['admins'] ) as $admin ) { - $formData['property_admins'][] = array( 'username' => $admin ); + $formData['property_admins'][] = [ 'username' => $admin ]; } } - $classes = array(); - $tallyTypes = array(); + $classes = []; + $tallyTypes = []; foreach ( SecurePoll_Ballot::$ballotTypes as $class ) { $classes[] = $class; - foreach ( call_user_func_array( array( $class, 'getTallyTypes' ), array() ) as $type ) { + foreach ( call_user_func_array( [ $class, 'getTallyTypes' ], [] ) as $type ) { $tallyTypes[$type] = true; } } @@ -700,9 +700,9 @@ } foreach ( $data['questions'] as $question ) { - $q = array( + $q = [ 'text' => $question['messages']['text'], - ); + ]; if ( isset( $question['id'] ) ) { $q['id'] = $question['id']; } @@ -713,9 +713,9 @@ // Process options for this question foreach ( $question['options'] as $option ) { - $o = array( + $o = [ 'text' => $option['messages']['text'], - ); + ]; if ( isset( $option['id'] ) ) { $o['id'] = $option['id']; } @@ -743,10 +743,10 @@ private static function insertEntity( $dbw, $type ) { $id = $dbw->nextSequenceValue( 'securepoll_en_id_seq' ); $dbw->insert( 'securepoll_entity', - array( + [ 'en_id' => $id, 'en_type' => $type, - ), + ], __METHOD__ ); $id = $dbw->insertId(); @@ -762,35 +762,35 @@ * @return array */ private static function savePropertiesAndMessages( $dbw, $id, $entity ) { - $properties = array(); + $properties = []; foreach ( $entity->getAllProperties() as $key => $value ) { - $properties[] = array( + $properties[] = [ 'pr_entity' => $id, 'pr_key' => $key, 'pr_value' => $value, - ); + ]; } $dbw->replace( - 'securepoll_properties', array( 'pr_entity', 'pr_key' ), $properties, __METHOD__ + 'securepoll_properties', [ 'pr_entity', 'pr_key' ], $properties, __METHOD__ ); - $messages = array(); + $messages = []; $langs = $entity->getLangList(); foreach ( $entity->getMessageNames() as $name ) { foreach ( $langs as $lang ) { $value = $entity->getRawMessage( $name, $lang ); if ( $value !== false ) { - $messages[] = array( + $messages[] = [ 'msg_entity' => $id, 'msg_lang' => $lang, 'msg_key' => $name, 'msg_text' => $value, - ); + ]; } } } $dbw->replace( - 'securepoll_msgs', array( 'msg_entity', 'msg_lang', 'msg_key' ), $messages, __METHOD__ + 'securepoll_msgs', [ 'msg_entity', 'msg_lang', 'msg_key' ], $messages, __METHOD__ ); } @@ -812,10 +812,10 @@ return; } - $items = call_user_func_array( array( $class, 'getCreateDescriptors' ), array() ); + $items = call_user_func_array( [ $class, 'getCreateDescriptors' ], [] ); if ( !is_array( $types ) ) { - $types = array( $types ); + $types = [ $types ]; } if ( $category ) { @@ -828,18 +828,18 @@ foreach ( $items as $key => $item ) { if ( !isset( $outItems[$key] ) ) { if ( !isset( $item['hide-if'] ) ) { - $item['hide-if'] = array( 'OR', array( 'AND' ) ); + $item['hide-if'] = [ 'OR', [ 'AND' ] ]; } else { - $item['hide-if'] = array( 'OR', array( 'AND' ), + $item['hide-if'] = [ 'OR', [ 'AND' ], $item['hide-if'] - ); + ]; } $outItems[$key] = $item; } else { // @todo Detect if this is really the same descriptor? } foreach ( $types as $type ) { - $outItems[$key]['hide-if'][1][] = array( '!==', $field, $type ); + $outItems[$key]['hide-if'][1][] = [ '!==', $field, $type ]; } } } @@ -859,7 +859,7 @@ return; } - $items = call_user_func_array( array( $class, 'getCreateDescriptors' ), array() ); + $items = call_user_func_array( [ $class, 'getCreateDescriptors' ], [] ); if ( $category ) { if ( !isset( $items[$category] ) ) { @@ -881,7 +881,7 @@ } break; case 'properties': - $formData[$key] = array(); + $formData[$key] = []; foreach ( $data['properties'] as $k => $v ) { $formData[$key][$k] = $v; } @@ -894,7 +894,7 @@ } break; case 'messages': - $formData[$key] = array(); + $formData[$key] = []; foreach ( $data['messages'] as $k => $v ) { $formData[$key][$k] = $v; } @@ -929,7 +929,7 @@ */ class SecurePoll_FormStore extends SecurePoll_MemoryStore { public $eId, $rId = 0; - public $qIds = array(), $oIds = array(); + public $qIds = [], $oIds = []; public $remoteWikis; private $lang; @@ -962,7 +962,7 @@ $wikis = (array)$wikis; } - $this->remoteWikis = array_diff( $wikis, array( wfWikiID() ) ); + $this->remoteWikis = array_diff( $wikis, [ wfWikiID() ] ); // Create the entry for the election list( $ballot, $tally ) = explode( '+', $formData['election_type'] ); @@ -981,7 +981,7 @@ $eId = (int)$formData['election_id'] <= 0 ? --$curId : (int)$formData['election_id']; $this->eId = $eId; - $this->entityInfo[$eId] = array( + $this->entityInfo[$eId] = [ 'id' => $eId, 'type' => 'election', 'title' => $formData['election_title'], @@ -992,9 +992,9 @@ 'endDate' => wfTimestamp( TS_MW, $endDate ), 'auth' => $this->remoteWikis ? 'remote-mw' : 'local', 'owner' => $userId, - 'questions' => array(), - ); - $this->properties[$eId] = array( + 'questions' => [], + ]; + $this->properties[$eId] = [ 'encrypt-type' => $crypt, 'wikis' => join( "\n", $wikis ), 'wikis-val' => isset( $formData['property_wiki'] ) @@ -1003,10 +1003,10 @@ 'return-url' => $formData['return-url'], 'disallow-change' => $formData['disallow-change'] ? 1 : 0, 'voter-privacy' => $formData['voter-privacy'] ? 1 : 0, - ); - $this->messages[$this->lang][$eId] = array( + ]; + $this->messages[$this->lang][$eId] = [ 'title' => $formData['election_title'], - ); + ]; $admins = $this->getAdminsList( $formData['property_admins'] ); $this->properties[$eId]['admins'] = $admins; @@ -1015,7 +1015,7 @@ $this->properties[$eId]['remote-mw-script-path'] = $wgSecurePollCreateRemoteScriptPath; $this->rId = $rId = --$curId; - $this->entityInfo[$rId] = array( + $this->entityInfo[$rId] = [ 'id' => $rId, 'type' => 'election', 'title' => $formData['election_title'], @@ -1025,17 +1025,17 @@ 'startDate' => wfTimestamp( TS_MW, $startDate ), 'endDate' => wfTimestamp( TS_MW, $endDate ), 'auth' => 'local', - 'questions' => array(), - ); + 'questions' => [], + ]; $this->properties[$rId]['main-wiki'] = wfWikiID(); $this->properties[$rId]['jump-url'] = SpecialPage::getTitleFor( 'SecurePoll' )->getFullUrl(); $this->properties[$rId]['jump-id'] = $eId; $this->properties[$rId]['admins'] = $admins; - $this->messages[$this->lang][$rId] = array( + $this->messages[$this->lang][$rId] = [ 'title' => $formData['election_title'], 'jump-text' => $formData['jump-text'], - ); + ]; } $this->processFormData( @@ -1056,16 +1056,16 @@ $qId = (int)$question['id']; $this->qIds[] = $qId; } - $this->entityInfo[$qId] = array( + $this->entityInfo[$qId] = [ 'id' => $qId, 'type' => 'question', 'election' => $eId, - 'options' => array(), - ); - $this->properties[$qId] = array(); - $this->messages[$this->lang][$qId] = array( + 'options' => [], + ]; + $this->properties[$qId] = []; + $this->messages[$this->lang][$qId] = [ 'text' => $question['text'], - ); + ]; $this->processFormData( $qId, $question, SecurePoll_Ballot::$ballotTypes[$ballot], 'question' @@ -1085,16 +1085,16 @@ $oId = (int)$option['id']; $this->oIds[] = $oId; } - $this->entityInfo[$oId] = array( + $this->entityInfo[$oId] = [ 'id' => $oId, 'type' => 'option', 'election' => $eId, 'question' => $qId, - ); - $this->properties[$oId] = array(); - $this->messages[$this->lang][$oId] = array( + ]; + $this->properties[$oId] = []; + $this->messages[$this->lang][$oId] = [ 'text' => $option['text'], - ); + ]; $this->processFormData( $oId, $option, SecurePoll_Ballot::$ballotTypes[$ballot], 'option' @@ -1128,7 +1128,7 @@ return; } - $items = call_user_func_array( array( $class, 'getCreateDescriptors' ), array() ); + $items = call_user_func_array( [ $class, 'getCreateDescriptors' ], [] ); if ( $category ) { if ( !isset( $items[$category] ) ) { @@ -1182,7 +1182,7 @@ public static function getWikiList() { global $wgConf; - $wikiNames = array(); + $wikiNames = []; foreach ( $wgConf->getLocalDatabases() as $dbname ) { $host = self::getWikiName( $dbname ); if ( strpos( $host, '.' ) ) { @@ -1208,7 +1208,7 @@ * @return string */ private function getAdminsList( $data ) { - $admins = array(); + $admins = []; foreach ( $data as $admin ) { $admins[] = User::getCanonicalName( $admin['username'] ); } diff --git a/includes/pages/DetailsPage.php b/includes/pages/DetailsPage.php index 3a4e85b..04bfd76 100644 --- a/includes/pages/DetailsPage.php +++ b/includes/pages/DetailsPage.php @@ -22,13 +22,13 @@ $db = $this->context->getDB(); $row = $db->selectRow( - array( 'securepoll_votes', 'securepoll_elections', 'securepoll_voters' ), + [ 'securepoll_votes', 'securepoll_elections', 'securepoll_voters' ], '*', - array( + [ 'vote_id' => $this->voteId, 'vote_election=el_entity', 'vote_voter=voter_id', - ), + ], __METHOD__ ); if ( !$row ) { @@ -50,10 +50,10 @@ $vote_ua = $row->vote_ua; } - $this->specialPage->setSubtitle( array( + $this->specialPage->setSubtitle( [ $this->specialPage->getTitle( 'list/' . $this->election->getId() ), $this->msg( 'securepoll-list-title', $this->election->getMessage( 'title' ) )->text() - ) ); + ] ); if ( !$this->election->isAdmin( $this->specialPage->getUser() ) ) { $out->addWikiMsg( 'securepoll-need-admin' ); @@ -115,7 +115,7 @@ '<td>' . Xml::element( 'a', - array( 'href' => $voter->getUrl() ), + [ 'href' => $voter->getUrl() ], $voter->getName() . '@' . $voter->getDomain() ) . '</td></tr>' @@ -167,15 +167,15 @@ } public function getQueryInfo() { - return array( - 'tables' => array( 'user', 'securepoll_strike' ), + return [ + 'tables' => [ 'user', 'securepoll_strike' ], 'fields' => '*', - 'conds' => array( + 'conds' => [ 'st_vote' => $this->voteId, 'st_user=user_id', - ), - 'options' => array() - ); + ], + 'options' => [] + ]; } public function formatValue( $name, $value ) { @@ -194,12 +194,12 @@ } function getFieldNames() { - return array( + return [ 'st_timestamp' => $this->msg( 'securepoll-header-timestamp' )->escaped(), 'st_user' => $this->msg( 'securepoll-header-admin' )->escaped(), 'st_action' => $this->msg( 'securepoll-header-action' )->escaped(), 'st_reason' => $this->msg( 'securepoll-header-reason' )->escaped(), - ); + ]; } function getTitle() { diff --git a/includes/pages/DumpPage.php b/includes/pages/DumpPage.php index 5b0261c..945606a 100644 --- a/includes/pages/DumpPage.php +++ b/includes/pages/DumpPage.php @@ -43,7 +43,7 @@ } $this->headersSent = false; - $status = $this->election->dumpVotesToCallback( array( $this, 'dumpVote' ) ); + $status = $this->election->dumpVotesToCallback( [ $this, 'dumpVote' ] ); if ( !$status->isOK() && !$this->headersSent ) { $out->addWikiText( $status->getWikiText() ); return; @@ -85,6 +85,6 @@ header( "Content-Disposition: attachment; filename=$filename" ); echo "<SecurePoll>\n<election>\n" . $this->election->getConfXml(); - $this->context->setLanguages( array( $this->election->getLanguage() ) ); + $this->context->setLanguages( [ $this->election->getLanguage() ] ); } } diff --git a/includes/pages/EntryPage.php b/includes/pages/EntryPage.php index 02f8224..0ea86ab 100644 --- a/includes/pages/EntryPage.php +++ b/includes/pages/EntryPage.php @@ -20,13 +20,13 @@ if ( $this->specialPage->getUser()->isAllowed( 'securepoll-create-poll' ) ) { $title = SpecialPage::getTitleFor( 'SecurePoll', 'create' ); $out->addHTML( - Html::rawElement( 'p', array(), + Html::rawElement( 'p', [], Linker::link( $title, $this->msg( 'securepoll-entry-createpoll' )->text(), - array(), - array(), - array( 'known' ) + [], + [], + [ 'known' ] ) ) ); @@ -45,49 +45,49 @@ * Pager for an election list. See TablePager documentation. */ class SecurePoll_ElectionPager extends TablePager { - public $subpages = array( - 'vote' => array( + public $subpages = [ + 'vote' => [ 'public' => true, 'visible-after-start' => true, 'visible-after-close' => false, - ), - 'translate' => array( + ], + 'translate' => [ 'public' => true, 'visible-after-start' => true, 'visible-after-close' => true, - ), - 'list' => array( + ], + 'list' => [ 'public' => true, 'visible-after-start' => true, 'visible-after-close' => true, - ), - 'edit' => array( + ], + 'edit' => [ 'public' => false, 'visible-after-start' => false, 'visible-after-close' => false, - ), - 'votereligibility' => array( + ], + 'votereligibility' => [ 'public' => false, 'visible-after-start' => true, 'visible-after-close' => true, - ), - 'dump' => array( + ], + 'dump' => [ 'public' => false, 'visible-after-start' => true, 'visible-after-close' => true, - ), - 'tally' => array( + ], + 'tally' => [ 'public' => false, 'visible-after-start' => true, 'visible-after-close' => true, - ), - ); - public $fields = array( + ], + ]; + public $fields = [ 'el_title', 'el_start_date', 'el_end_date', 'links' - ); + ]; public $entryPage; public function __construct( $specialPage ) { @@ -96,18 +96,18 @@ } public function getQueryInfo() { - return array( + return [ 'tables' => 'securepoll_elections', 'fields' => '*', 'conds' => false, - 'options' => array() - ); + 'options' => [] + ]; } public function isFieldSortable( $field ) { - return in_array( $field, array( + return in_array( $field, [ 'el_title', 'el_start_date', 'el_end_date' - ) ); + ] ); } /** @@ -178,7 +178,7 @@ } public function getFieldNames() { - $names = array(); + $names = []; foreach ( $this->fields as $field ) { if ( $field == 'links' ) { $names[$field] = ''; @@ -187,7 +187,7 @@ // securepoll-header-title, securepoll-header-start-date, // securepoll-header-end-date $msgName = 'securepoll-header-' . - strtr( $field, array( 'el_' => '', '_' => '-' ) ); + strtr( $field, [ 'el_' => '', '_' => '-' ] ); $names[$field] = $this->msg( $msgName )->text(); } } diff --git a/includes/pages/ListPage.php b/includes/pages/ListPage.php index 742562f..710670a 100644 --- a/includes/pages/ListPage.php +++ b/includes/pages/ListPage.php @@ -42,39 +42,39 @@ $res = $dbr->select( 'securepoll_votes', - array( 'DISTINCT vote_voter' ), - array( + [ 'DISTINCT vote_voter' ], + [ 'vote_election' => $this->election->getID() - ) + ] ); $distinct_voters = $res->result->num_rows; $res = $dbr->select( 'securepoll_votes', - array( 'vote_id' ), - array( + [ 'vote_id' ], + [ 'vote_election' => $this->election->getID() - ) + ] ); $all_votes = $res->result->num_rows; $res = $dbr->select( 'securepoll_votes', - array( 'vote_id' ), - array( + [ 'vote_id' ], + [ 'vote_election' => $this->election->getID(), 'vote_current' => 0 - ) + ] ); $not_current_votes = $res->result->num_rows; $res = $dbr->select( 'securepoll_votes', - array( 'vote_id' ), - array( + [ 'vote_id' ], + [ 'vote_election' => $this->election->getID(), 'vote_struck' => 1 - ) + ] ); $struck_votes = $res->result->num_rows; @@ -98,10 +98,10 @@ $msgCancel = $this->msg( 'securepoll-strike-cancel' )->escaped(); $msgReason = $this->msg( 'securepoll-strike-reason' )->escaped(); $encAction = htmlspecialchars( $this->getTitle()->getLocalUrl() ); - $script = Skin::makeVariablesScript( array( + $script = Skin::makeVariablesScript( [ 'securepoll_strike_button' => $this->msg( 'securepoll-strike-button' )->text(), 'securepoll_unstrike_button' => $this->msg( 'securepoll-unstrike-button' )->text() - ) ); + ] ); // @codingStandardsIgnoreStart $out->addHTML( <<<EOT @@ -151,20 +151,20 @@ // Add it to the strike log $strikeId = $dbw->nextSequenceValue( 'securepoll_strike_st_id' ); $dbw->insert( 'securepoll_strike', - array( + [ 'st_id' => $strikeId, 'st_vote' => $voteId, 'st_timestamp' => wfTimestampNow( TS_DB ), 'st_action' => $action, 'st_reason' => $reason, 'st_user' => $this->specialPage->getUser()->getId() - ), + ], __METHOD__ ); // Update the status cache $dbw->update( 'securepoll_votes', - array( 'vote_struck' => intval( $action == 'strike' ) ), - array( 'vote_id' => $voteId ), + [ 'vote_struck' => intval( $action == 'strike' ) ], + [ 'vote_id' => $voteId ], __METHOD__ ); $dbw->endAtomic( __METHOD__ ); @@ -188,13 +188,13 @@ class SecurePoll_ListPager extends TablePager { public $listPage, $isAdmin, $election; - public static $publicFields = array( + public static $publicFields = [ 'vote_timestamp', 'vote_voter_name', 'vote_voter_domain', - ); + ]; - public static $adminFields = array( + public static $adminFields = [ 'details', 'strike', 'vote_timestamp', @@ -205,7 +205,7 @@ 'vote_ua', 'vote_token_match', 'vote_cookie_dup', - ); + ]; public function __construct( $listPage ) { $this->listPage = $listPage; @@ -215,26 +215,26 @@ } public function getQueryInfo() { - return array( + return [ 'tables' => 'securepoll_votes', 'fields' => '*', - 'conds' => array( + 'conds' => [ 'vote_election' => $this->listPage->election->getId() - ), - 'options' => array() - ); + ], + 'options' => [] + ]; } public function isFieldSortable( $field ) { - return in_array( $field, array( + return in_array( $field, [ 'vote_voter_name', 'vote_voter_domain', 'vote_timestamp', 'vote_ip' - ) ); + ] ); } public function formatValue( $name, $value ) { global $wgScriptPath, $wgSecurePollKeepPrivateInfoDays; - $critical = Xml::element( 'img', array( - 'src' => "$wgScriptPath/extensions/SecurePoll/resources/critical-32.png" ) + $critical = Xml::element( 'img', [ + 'src' => "$wgScriptPath/extensions/SecurePoll/resources/critical-32.png" ] ); $voter = SecurePoll_Voter::newFromId( $this->listPage->context, @@ -281,7 +281,7 @@ $voteId = intval( $this->mCurrentRow->vote_id ); $title = $this->listPage->specialPage->getTitle( "details/$voteId" ); return Xml::element( 'a', - array( 'href' => $title->getLocalUrl() ), + [ 'href' => $title->getLocalUrl() ], $this->msg( 'securepoll-details-link' )->text() ); break; @@ -296,19 +296,19 @@ } $id = 'securepoll-popup-' . $voteId; return Xml::element( 'input', - array( + [ 'type' => 'button', 'id' => $id, 'value' => $label, 'onclick' => "securepoll_strike_popup(event, $action, $voteId)" - ) ); + ] ); case 'vote_voter_name': $msg = $voter->isRemote() ? 'securepoll-voter-name-remote' : 'securepoll-voter-name-local'; return $this->msg( $msg, - array( $value ) + [ $value ] )->parse(); default: return htmlspecialchars( $value ); @@ -320,7 +320,7 @@ } public function getFieldNames() { - $names = array(); + $names = []; if ( $this->isAdmin ) { $fields = self::$adminFields; } else { @@ -333,13 +333,13 @@ // securepoll-header-cookie-dup foreach ( $fields as $field ) { $names[$field] = $this->msg( 'securepoll-header-' . strtr( $field, - array( 'vote_' => '', '_' => '-' ) ) )->text(); + [ 'vote_' => '', '_' => '-' ] ) )->text(); } return $names; } public function getRowClass( $row ) { - $classes = array(); + $classes = []; if ( !$row->vote_current ) { $classes[] = 'securepoll-old-vote'; } diff --git a/includes/pages/MessageDumpPage.php b/includes/pages/MessageDumpPage.php index bc5beea..08e6336 100644 --- a/includes/pages/MessageDumpPage.php +++ b/includes/pages/MessageDumpPage.php @@ -22,15 +22,15 @@ header( "Content-Disposition: attachment; filename=$filename" ); $dbr = $this->context->getDB(); - $entities = array_merge( array( $this->election ), $this->election->getDescendants() ); - $ids = array(); + $entities = array_merge( [ $this->election ], $this->election->getDescendants() ); + $ids = []; foreach ( $entities as $entity ) { $ids[] = $entity->getId(); } $res = $dbr->select( 'securepoll_msgs', '*', - array( 'msg_entity' => $ids ), + [ 'msg_entity' => $ids ], __METHOD__ ); if ( !$res->numRows() ) { return; @@ -38,18 +38,18 @@ echo "INSERT INTO securepoll_msgs (msg_entity,msg_lang, msg_key, msg_text) VALUES\n"; $first = true; foreach ( $res as $row ) { - $values = array( + $values = [ $row->msg_entity, $row->msg_lang, $row->msg_key, $row->msg_text - ); + ]; if ( $first ) { $first = false; } else { echo ",\n"; } - echo '(' . implode( ', ', array_map( array( $dbr, 'addQuotes' ), $values ) ) . ')'; + echo '(' . implode( ', ', array_map( [ $dbr, 'addQuotes' ], $values ) ) . ')'; } echo ";\n"; } diff --git a/includes/pages/TallyPage.php b/includes/pages/TallyPage.php index 507581d..03ea4a3 100644 --- a/includes/pages/TallyPage.php +++ b/includes/pages/TallyPage.php @@ -74,7 +74,7 @@ $out->addHTML( Xml::openElement( 'form', - array( 'method' => 'post', 'action' => $this->getTitle()->getLocalUrl() ) + [ 'method' => 'post', 'action' => $this->getTitle()->getLocalUrl() ] ) . "\n" . Xml::fieldset( @@ -82,7 +82,7 @@ '<div>' . Xml::submitButton( $this->msg( 'securepoll-tally-local-submit' )->text(), - array( 'name' => 'submit_local' ) + [ 'name' => 'submit_local' ] ) . '</div>' ) . @@ -97,25 +97,25 @@ $this->specialPage->getOutput()->addHTML( Xml::openElement( 'form', - array( + [ 'method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'enctype' => 'multipart/form-data' - ) + ] ) . "\n" . Xml::fieldset( $this->msg( 'securepoll-tally-upload-legend' )->text(), '<div>' . - Xml::element( 'input', array( + Xml::element( 'input', [ 'type' => 'file', 'name' => 'tally_file', 'size' => 40, - ) ) . + ] ) . "</div>\n<div>" . Xml::submitButton( $this->msg( 'securepoll-tally-upload-submit' )->text(), - array( 'name' => 'submit_upload' ) + [ 'name' => 'submit_upload' ] ) . "</div>\n" ) . diff --git a/includes/pages/TranslatePage.php b/includes/pages/TranslatePage.php index a6f43a6..7686dee 100644 --- a/includes/pages/TranslatePage.php +++ b/includes/pages/TranslatePage.php @@ -82,10 +82,10 @@ } # Set a subtitle to return to the language selector - $this->specialPage->setSubtitle( array( + $this->specialPage->setSubtitle( [ $this->getTitle(), $this->msg( 'securepoll-translate-title', $this->election->getMessage( 'title' ) )->text() - ) ); + ] ); # If the request was posted, do the submit if ( $request->wasPosted() && $request->getVal( 'action' ) == 'submit' ) { @@ -96,7 +96,7 @@ # Show the form $action = $this->getTitle( $secondary )->getLocalUrl( 'action=submit' ); $s = - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) . + Xml::openElement( 'form', [ 'method' => 'post', 'action' => $action ] ) . '<table class="mw-datatable TablePager securepoll-trans-table">' . '<col class="securepoll-col-trans-id" width="1*"/>' . '<col class="securepoll-col-primary" width="30%"/>' . @@ -104,14 +104,14 @@ '<tr><th>' . $this->msg( 'securepoll-header-trans-id' )->escaped() . '</th>' . '<th>' . htmlspecialchars( $primaryName ) . '</th>' . '<th>' . htmlspecialchars( $secondaryName ) . '</th></tr>'; - $entities = array_merge( array( $this->election ), $this->election->getDescendants() ); + $entities = array_merge( [ $this->election ], $this->election->getDescendants() ); foreach ( $entities as $entity ) { $entityName = $entity->getType() . '(' . $entity->getId() . ')'; foreach ( $entity->getMessageNames() as $messageName ) { $controlName = 'trans_' . $entity->getId() . '_' . $messageName; $primaryText = $entity->getRawMessage( $messageName, $primary ); $secondaryText = $entity->getRawMessage( $messageName, $secondary ); - $attribs = array( 'class' => 'securepoll-translate-box' ); + $attribs = [ 'class' => 'securepoll-translate-box' ]; if ( !$this->isAdmin ) { $attribs['readonly'] = '1'; } @@ -128,7 +128,7 @@ $s .= '<p style="text-align: center;">' . wfMessage( 'securepoll-translate-label-comment' )->escaped() . - Xml::input( 'comment', 45, false, array( 'maxlength' => 250 ) ) . + Xml::input( 'comment', 45, false, [ 'maxlength' => 250 ] ) . "</p>"; } @@ -159,13 +159,13 @@ public function showLanguageSelector( $selectedCode ) { $s = Xml::openElement( 'form', - array( + [ 'action' => $this->getTitle( false )->getLocalUrl() - ) + ] ) . Xml::openElement( 'select', - array( 'id' => 'secondary_lang', 'name' => 'secondary_lang' ) + [ 'id' => 'secondary_lang', 'name' => 'secondary_lang' ] ) . "\n"; $languages = Language::fetchLanguageNames(); @@ -193,29 +193,29 @@ return; } - $entities = array_merge( array( $this->election ), $this->election->getDescendants() ); - $replaceBatch = array(); - $jumpReplaceBatch = array(); + $entities = array_merge( [ $this->election ], $this->election->getDescendants() ); + $replaceBatch = []; + $jumpReplaceBatch = []; foreach ( $entities as $entity ) { foreach ( $entity->getMessageNames() as $messageName ) { $controlName = 'trans_' . $entity->getId() . '_' . $messageName; $value = $request->getText( $controlName ); if ( $value !== '' ) { - $replaceBatch[] = array( + $replaceBatch[] = [ 'msg_entity' => $entity->getId(), 'msg_lang' => $secondary, 'msg_key' => $messageName, 'msg_text' => $value - ); + ]; // Jump wikis don't have subentities if ( $entity === $this->election ) { - $jumpReplaceBatch[] = array( + $jumpReplaceBatch[] = [ 'msg_entity' => $entity->getId(), 'msg_lang' => $secondary, 'msg_key' => $messageName, 'msg_text' => $value - ); + ]; } } } @@ -225,14 +225,14 @@ if ( $wikis ) { $wikis = explode( "\n", $wikis ); } else { - $wikis = array(); + $wikis = []; } // First, the main wiki $dbw = $this->context->getDB(); $dbw->replace( 'securepoll_msgs', - array( array( 'msg_entity', 'msg_lang', 'msg_key' ) ), + [ [ 'msg_entity', 'msg_lang', 'msg_key' ] ], $replaceBatch, __METHOD__ ); @@ -255,11 +255,11 @@ } $lb = wfGetLB( $dbname ); - $dbw = $lb->getConnection( DB_MASTER, array(), $dbname ); + $dbw = $lb->getConnection( DB_MASTER, [], $dbname ); try { - $id = $dbw->selectField( 'securepoll_elections', 'el_entity', array( + $id = $dbw->selectField( 'securepoll_elections', 'el_entity', [ 'el_title' => $this->election->title - ) ); + ] ); if ( $id ) { foreach ( $jumpReplaceBatch as &$row ) { $row['msg_entity'] = $id; @@ -268,7 +268,7 @@ $dbw->replace( 'securepoll_msgs', - array( array( 'msg_entity', 'msg_lang', 'msg_key' ) ), + [ [ 'msg_entity', 'msg_lang', 'msg_key' ] ], $jumpReplaceBatch, __METHOD__ ); diff --git a/includes/pages/VotePage.php b/includes/pages/VotePage.php index eb0a4dd..02066cb 100644 --- a/includes/pages/VotePage.php +++ b/includes/pages/VotePage.php @@ -169,11 +169,11 @@ # Mark previous votes as old $dbw->update( 'securepoll_votes', - array( 'vote_current' => 0 ), # SET - array( # WHERE + [ 'vote_current' => 0 ], # SET + [ # WHERE 'vote_election' => $this->election->getId(), 'vote_voter' => $this->voter->getId(), - ), + ], __METHOD__ ); @@ -187,7 +187,7 @@ $voteId = $dbw->nextSequenceValue( 'securepoll_votes_vote_id' ); $dbw->insert( 'securepoll_votes', - array( + [ 'vote_id' => $voteId, 'vote_election' => $this->election->getId(), 'vote_voter' => $this->voter->getId(), @@ -200,7 +200,7 @@ 'vote_timestamp' => $now, 'vote_current' => 1, 'vote_token_match' => $tokenMatch ? 1 : 0, - ), + ], __METHOD__ ); $voteId = $dbw->insertId(); $dbw->endAtomic( __METHOD__ ); @@ -242,10 +242,10 @@ throw new MWException( 'Configuration error: no jump-id' ); } $url .= "/login/$id"; - Hooks::run( 'SecurePoll_JumpUrl', array( $this, &$url ) ); + Hooks::run( 'SecurePoll_JumpUrl', [ $this, &$url ] ); $out->addWikiText( $this->election->getMessage( 'jump-text' ) ); $out->addHTML( - Xml::openElement( 'form', array( 'action' => $url, 'method' => 'post' ) ) . + Xml::openElement( 'form', [ 'action' => $url, 'method' => 'post' ] ) . Html::hidden( 'token', SecurePoll_RemoteMWAuth::encodeToken( $user->getToken() ) ) . Html::hidden( 'id', $user->getId() ) . Html::hidden( 'wiki', wfWikiID() ) . diff --git a/includes/pages/VoterEligibilityPage.php b/includes/pages/VoterEligibilityPage.php index b06b152..322552e 100644 --- a/includes/pages/VoterEligibilityPage.php +++ b/includes/pages/VoterEligibilityPage.php @@ -4,11 +4,11 @@ * Special:SecurePoll subpage for managing the voter list for a poll */ class SecurePoll_VoterEligibilityPage extends SecurePoll_ActionPage { - private static $lists = array( + private static $lists = [ 'voter' => 'need-list', 'include' => 'include-list', 'exclude' => 'exclude-list', - ); + ]; /** * Execute the subpage. @@ -90,7 +90,7 @@ } array_unshift( $wikis, $localWiki ); } else { - $wikis = array( $localWiki ); + $wikis = [ $localWiki ]; } foreach ( $wikis as $dbname ) { @@ -99,7 +99,7 @@ } else { $lb = wfGetLB( $dbname ); unset( $dbw ); // trigger DBConnRef destruction and connection reuse - $dbw = $lb->getConnectionRef( DB_MASTER, array(), $dbname ); + $dbw = $lb->getConnectionRef( DB_MASTER, [], $dbname ); try { // Connect to the DB and check if the LB is in read-only mode if ( $dbw->isReadOnly() ) { @@ -120,13 +120,13 @@ __METHOD__ ); if ( $id ) { - $ins = array(); + $ins = []; foreach ( $properties as $key => $value ) { - $ins[] = array( + $ins[] = [ 'pr_entity' => $id, 'pr_key' => $key, 'pr_value' => $value, - ); + ]; } $dbw->delete( @@ -168,35 +168,35 @@ $wikis[] = wfWikiID(); } } else { - $wikis = array( wfWikiID() ); + $wikis = [ wfWikiID() ]; } - $names = array(); + $names = []; foreach ( $wikis as $dbname ) { - $dbr = wfGetDB( $db, array(), $dbname ); + $dbr = wfGetDB( $db, [], $dbname ); - $id = $dbr->selectField( 'securepoll_elections', 'el_entity', array( + $id = $dbr->selectField( 'securepoll_elections', 'el_entity', [ 'el_title' => $this->election->title - ) ); + ] ); if ( !$id ) { // WTF? continue; } - $list = $dbr->selectField( 'securepoll_properties', 'pr_value', array( + $list = $dbr->selectField( 'securepoll_properties', 'pr_value', [ 'pr_entity' => $id, 'pr_key' => $property, - ) ); + ] ); if ( !$list ) { continue; } $res = $dbr->select( - array( 'securepoll_lists', 'user' ), - array( 'user_name' ), - array( + [ 'securepoll_lists', 'user' ], + [ 'user_name' ], + [ 'li_name' => $list, 'user_id=li_member', - ) + ] ); foreach ( $res as $row ) { $names[] = str_replace( '_', ' ', $row->user_name ) . "@$dbname"; @@ -217,10 +217,10 @@ $wikis[] = wfWikiID(); } } else { - $wikis = array( wfWikiID() ); + $wikis = [ wfWikiID() ]; } - $wikiNames = array( '*' => array() ); + $wikiNames = [ '*' => [] ]; foreach ( explode( "\n", $names ) as $name ) { $name = trim( $name ); $i = strrpos( $name, '@' ); @@ -247,7 +247,7 @@ } array_unshift( $wikis, $localWiki ); } else { - $wikis = array( $localWiki ); + $wikis = [ $localWiki ]; } foreach ( $wikis as $dbname ) { @@ -255,7 +255,7 @@ $dbw = $this->context->getDB(); } else { unset( $dbw ); // trigger DBConnRef destruction and connection reuse - $dbw = wfGetLB( $dbname )->getConnectionRef( DB_MASTER, array(), $dbname ); + $dbw = wfGetLB( $dbname )->getConnectionRef( DB_MASTER, [], $dbname ); try { // Connect to the DB and check if the LB is in read-only mode if ( $dbw->isReadOnly() ) { @@ -341,15 +341,15 @@ $out = $this->specialPage->getOutput(); $out->setPageTitle( $this->msg( 'securepoll-votereligibility-title' ) ); - $formItems = array(); + $formItems = []; - $formItems['min-edits'] = array( + $formItems['min-edits'] = [ 'section' => 'basic', 'label-message' => 'securepoll-votereligibility-label-min_edits', 'type' => 'int', 'min' => 0, 'default' => $this->election->getProperty( 'min-edits', '' ), - ); + ]; $date = $this->election->getProperty( 'max-registration', '' ); if ( $date !== '' ) { @@ -357,62 +357,62 @@ } else { $date = gmdate( 'Y-m-d', strtotime( 'yesterday' ) ); } - $formItems['max-registration'] = array( + $formItems['max-registration'] = [ 'section' => 'basic', 'label-message' => 'securepoll-votereligibility-label-max_registration', 'type' => 'date', 'default' => $date, - ); + ]; - $formItems['not-blocked'] = array( + $formItems['not-blocked'] = [ 'section' => 'basic', 'label-message' => 'securepoll-votereligibility-label-not_blocked', 'type' => 'check', 'hidelabel' => true, 'default' => $this->election->getProperty( 'not-blocked', false ), - ); + ]; - $formItems['not-centrally-blocked'] = array( + $formItems['not-centrally-blocked'] = [ 'section' => 'basic', 'label-message' => 'securepoll-votereligibility-label-not_centrally_blocked', 'type' => 'check', 'hidelabel' => true, 'default' => $this->election->getProperty( 'not-centrally-blocked', false ), - ); + ]; - $formItems['central-block-threshold'] = array( + $formItems['central-block-threshold'] = [ 'section' => 'basic', 'label-message' => 'securepoll-votereligibility-label-central_block_threshold', 'type' => 'int', 'min' => 1, 'required' => true, - 'hide-if' => array( '===', 'not-centrally-blocked', '' ), + 'hide-if' => [ '===', 'not-centrally-blocked', '' ], 'default' => $this->election->getProperty( 'central-block-threshold', '' ), - ); + ]; - $formItems['not-bot'] = array( + $formItems['not-bot'] = [ 'section' => 'basic', 'label-message' => 'securepoll-votereligibility-label-not_bot', 'type' => 'check', 'hidelabel' => true, 'default' => $this->election->getProperty( 'not-bot', false ), - ); + ]; - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, 'default' => Html::openElement( 'dl' ), - ); + ]; foreach ( self::$lists as $list => $property ) { $name = $this->msg( "securepoll-votereligibility-list-$list" )->text(); - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, - 'default' => Html::rawElement( 'dt', array(), $name ) . + 'default' => Html::rawElement( 'dt', [], $name ) . Html::openElement( 'dd' ) . Html::openElement( 'ul' ), - ); + ]; $use = null; if ( $list === 'voter' ) { @@ -422,24 +422,24 @@ $use = $this->msg( 'securepoll-votereligibility-label-processing' ) ->numParams( round( $complete * 100.0 / $total, 1 ) ) ->numParams( $complete, $total ); - $links = array( 'clear' ); + $links = [ 'clear' ]; } } if ( $use === null && $this->election->getProperty( $property ) ) { $use = $this->msg( 'securepoll-votereligibility-label-inuse' ); - $links = array( 'edit', 'clear' ); + $links = [ 'edit', 'clear' ]; } if ( $use === null ) { $use = $this->msg( 'securepoll-votereligibility-label-notinuse' ); - $links = array( 'edit' ); + $links = [ 'edit' ]; } - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, - 'default' => Html::rawElement( 'li', array(), $use->parse() ), - ); + 'default' => Html::rawElement( 'li', [], $use->parse() ), + ]; $prefix = 'votereligibility/' . $this->election->getId(); foreach ( $links as $action ) { @@ -447,50 +447,50 @@ $link = Linker::link( $title, $this->msg( "securepoll-votereligibility-label-$action" )->parse() ); - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, - 'default' => Html::rawElement( 'li', array(), $link ), - ); + 'default' => Html::rawElement( 'li', [], $link ), + ]; } if ( $list === 'voter' ) { - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, 'default' => Html::openElement( 'li' ), - ); + ]; - $formItems['list_populate'] = array( + $formItems['list_populate'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-populate', 'type' => 'check', 'hidelabel' => true, 'default' => $this->election->getProperty( 'list_populate', false ), - ); + ]; - $formItems['list_edits-before'] = array( + $formItems['list_edits-before'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_before', 'type' => 'check', 'default' => $this->election->getProperty( 'list_edits-before', false ), - 'hide-if' => array( '===', 'list_populate', '' ), - ); + 'hide-if' => [ '===', 'list_populate', '' ], + ]; - $formItems['list_edits-before-count'] = array( + $formItems['list_edits-before-count'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_before_count', 'type' => 'int', 'min' => 1, 'required' => true, - 'hide-if' => array( 'OR', - array( '===', 'list_populate', '' ), - array( '===', 'list_edits-before', '' ), - ), + 'hide-if' => [ 'OR', + [ '===', 'list_populate', '' ], + [ '===', 'list_edits-before', '' ], + ], 'default' => $this->election->getProperty( 'list_edits-before-count', '' ), - ); + ]; $date = $this->election->getProperty( 'list_edits-before-date', '' ); if ( $date !== '' ) { @@ -498,39 +498,39 @@ } else { $date = gmdate( 'Y-m-d', strtotime( 'yesterday' ) ); } - $formItems['list_edits-before-date'] = array( + $formItems['list_edits-before-date'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_before_date', 'type' => 'date', 'max' => gmdate( 'Y-m-d', strtotime( 'yesterday' ) ), 'required' => true, - 'hide-if' => array( 'OR', - array( '===', 'list_populate', '' ), - array( '===', 'list_edits-before', '' ), - ), + 'hide-if' => [ 'OR', + [ '===', 'list_populate', '' ], + [ '===', 'list_edits-before', '' ], + ], 'default' => $date, - ); + ]; - $formItems['list_edits-between'] = array( + $formItems['list_edits-between'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_between', 'type' => 'check', - 'hide-if' => array( '===', 'list_populate', '' ), + 'hide-if' => [ '===', 'list_populate', '' ], 'default' => $this->election->getProperty( 'list_edits-between', false ), - ); + ]; - $formItems['list_edits-between-count'] = array( + $formItems['list_edits-between-count'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_between_count', 'type' => 'int', 'min' => 1, 'required' => true, - 'hide-if' => array( 'OR', - array( '===', 'list_populate', '' ), - array( '===', 'list_edits-between', '' ), - ), + 'hide-if' => [ 'OR', + [ '===', 'list_populate', '' ], + [ '===', 'list_edits-between', '' ], + ], 'default' => $this->election->getProperty( 'list_edits-between-count', '' ), - ); + ]; $editCountStartDate = $this->election->getProperty( 'list_edits-startdate', '' ); if ( $editCountStartDate !== '' ) { @@ -538,18 +538,18 @@ wfTimestamp( TS_UNIX, $editCountStartDate ) ); } - $formItems['list_edits-startdate'] = array( + $formItems['list_edits-startdate'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_startdate', 'type' => 'date', 'max' => gmdate( 'Y-m-d', strtotime( 'yesterday' ) ), 'required' => true, - 'hide-if' => array( 'OR', - array( '===', 'list_populate', '' ), - array( '===', 'list_edits-between', '' ), - ), + 'hide-if' => [ 'OR', + [ '===', 'list_populate', '' ], + [ '===', 'list_edits-between', '' ], + ], 'default' => $editCountStartDate, - ); + ]; $editCountEndDate = $this->election->getProperty( 'list_edits-enddate', '' ); if ( $editCountEndDate === '' ) { @@ -559,90 +559,90 @@ wfTimestamp( TS_UNIX, $editCountEndDate ) ); } - $formItems['list_edits-enddate'] = array( + $formItems['list_edits-enddate'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-edits_enddate', 'type' => 'date', 'max' => gmdate( 'Y-m-d', strtotime( 'yesterday' ) ), 'required' => true, - 'hide-if' => array( 'OR', - array( '===', 'list_populate', '' ), - array( '===', 'list_edits-between', '' ), - ), + 'hide-if' => [ 'OR', + [ '===', 'list_populate', '' ], + [ '===', 'list_edits-between', '' ], + ], 'default' => $editCountEndDate, - ); + ]; - $groups = $this->election->getProperty( 'list_exclude-groups', array() ); + $groups = $this->election->getProperty( 'list_exclude-groups', [] ); if ( $groups ) { $groups = array_map( function ( $group ) { - return array( 'group' => $group ); + return [ 'group' => $group ]; }, explode( '|', $groups ) ); } - $formItems['list_exclude-groups'] = array( + $formItems['list_exclude-groups'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-exclude_groups', 'type' => 'cloner', 'format' => 'raw', 'default' => $groups, - 'fields' => array( - 'group' => array( + 'fields' => [ + 'group' => [ 'type' => 'text', 'required' => true, - ), - ), - 'hide-if' => array( '===', 'list_populate', '' ), - ); + ], + ], + 'hide-if' => [ '===', 'list_populate', '' ], + ]; - $groups = $this->election->getProperty( 'list_include-groups', array() ); + $groups = $this->election->getProperty( 'list_include-groups', [] ); if ( $groups ) { $groups = array_map( function ( $group ) { - return array( 'group' => $group ); + return [ 'group' => $group ]; }, explode( '|', $groups ) ); } - $formItems['list_include-groups'] = array( + $formItems['list_include-groups'] = [ 'section' => 'lists', 'label-message' => 'securepoll-votereligibility-label-include_groups', 'type' => 'cloner', 'format' => 'raw', 'default' => $groups, - 'fields' => array( - 'group' => array( + 'fields' => [ + 'group' => [ 'type' => 'text', 'required' => true, - ), - ), - 'hide-if' => array( '===', 'list_populate', '' ), - ); + ], + ], + 'hide-if' => [ '===', 'list_populate', '' ], + ]; - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, 'default' => Html::closeElement( 'li' ), - ); + ]; } - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, 'default' => '</ul></dd>', - ); + ]; } - $formItems[] = array( + $formItems[] = [ 'section' => 'lists', 'type' => 'info', 'rawrow' => true, 'default' => Html::closeElement( 'dl' ), - ); + ]; if ( $wgSecurePollUseNamespace ) { - $formItems['comment'] = array( + $formItems['comment'] = [ 'type' => 'text', 'label-message' => 'securepoll-votereligibility-label-comment', 'maxlength' => 250, - ); + ]; } $form = HTMLForm::factory( @@ -656,7 +656,7 @@ ); $form->setSubmitTextMsg( 'securepoll-votereligibility-action' ); - $form->setSubmitCallback( array( $this, 'processConfig' ) ); + $form->setSubmitCallback( [ $this, 'processConfig' ] ); $result = $form->show(); if ( $result === true || ( $result instanceof Status && $result->isGood() ) ) { @@ -680,19 +680,19 @@ } public function processConfig( $formData, $form ) { - static $props = array( + static $props = [ 'min-edits', 'not-blocked', 'not-centrally-blocked', 'central-block-threshold', 'not-bot', 'list_populate', 'list_edits-before', 'list_edits-before-count', 'list_edits-between', 'list_edits-between-count', - ); - static $dateProps = array( + ]; + static $dateProps = [ 'max-registration', 'list_edits-before-date', 'list_edits-startdate', 'list_edits-enddate', - ); - static $listProps = array( + ]; + static $listProps = [ 'list_exclude-groups', 'list_include-groups', - ); + ]; if ( $formData['list_populate'] && !$formData['list_edits-before'] && @@ -703,8 +703,8 @@ return Status::newFatal( 'securepoll-votereligibility-fail-nothing-to-process' ); } - $properties = array(); - $deleteProperties = array(); + $properties = []; + $deleteProperties = []; foreach ( $props as $prop ) { if ( $formData[$prop] !== '' && $formData[$prop] !== false ) { @@ -715,7 +715,7 @@ } foreach ( $dateProps as $prop ) { - if ( $formData[$prop] !== '' && $formData[$prop] !== array() ) { + if ( $formData[$prop] !== '' && $formData[$prop] !== [] ) { $dates = array_map( function ( $date ) { $date = new DateTime( $date, new DateTimeZone( 'GMT' ) ); return wfTimestamp( TS_MW, $date->format( 'YmdHis' ) ); @@ -793,21 +793,21 @@ $out = $this->specialPage->getOutput(); $out->setPageTitle( $this->msg( 'securepoll-votereligibility-edit-title', $name ) ); - $formItems = array(); + $formItems = []; - $formItems['names'] = array( + $formItems['names'] = [ 'label-message' => 'securepoll-votereligibility-label-names', 'type' => 'textarea', 'rows' => 20, 'default' => join( "\n", $this->fetchList( $property ) ), - ); + ]; if ( $wgSecurePollUseNamespace ) { - $formItems['comment'] = array( + $formItems['comment'] = [ 'type' => 'text', 'label-message' => 'securepoll-votereligibility-label-comment', 'maxlength' => 250, - ); + ]; } $form = new HTMLForm( @@ -857,7 +857,7 @@ $wikis[] = wfWikiID(); } } else { - $wikis = array( wfWikiID() ); + $wikis = [ wfWikiID() ]; } $localWiki = wfWikiID(); @@ -870,7 +870,7 @@ } array_unshift( $wikis, $localWiki ); } else { - $wikis = array( $localWiki ); + $wikis = [ $localWiki ]; } foreach ( $wikis as $dbname ) { @@ -879,34 +879,34 @@ } else { $lb = wfGetLB( $dbname ); unset( $dbw ); // trigger DBConnRef destruction and connection reuse - $dbw = $lb->getConnectionRef( DB_MASTER, array(), $dbname ); + $dbw = $lb->getConnectionRef( DB_MASTER, [], $dbname ); } $dbw->startAtomic( __METHOD__ ); - $id = $dbw->selectField( 'securepoll_elections', 'el_entity', array( + $id = $dbw->selectField( 'securepoll_elections', 'el_entity', [ 'el_title' => $this->election->title - ) ); + ] ); if ( $id ) { - $list = $dbw->selectField( 'securepoll_properties', 'pr_value', array( + $list = $dbw->selectField( 'securepoll_properties', 'pr_value', [ 'pr_entity' => $id, 'pr_key' => $property, - ) ); + ] ); if ( $list ) { - $dbw->delete( 'securepoll_lists', array( 'li_name' => $list ) ); + $dbw->delete( 'securepoll_lists', [ 'li_name' => $list ] ); $dbw->delete( 'securepoll_properties', - array( 'pr_entity' => $id, 'pr_key' => $property ) ); + [ 'pr_entity' => $id, 'pr_key' => $property ] ); } if ( $which === 'voter' ) { - $dbw->delete( 'securepoll_properties', array( + $dbw->delete( 'securepoll_properties', [ 'pr_entity' => $id, - 'pr_key' => array( + 'pr_key' => [ 'list_populate', 'list_job-key', 'list_total-count', 'list_complete-count', 'list_job-key', - ), - ) ); + ], + ] ); } } -- To view, visit https://gerrit.wikimedia.org/r/358073 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I17aa9005f8b2cf4fcd8c2455dc0000b9b3c017c1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SecurePoll Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Huji <huji.h...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits