jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/357392 )
Change subject: Make phpcs pass - api / maintenance / tests ...................................................................... Make phpcs pass - api / maintenance / tests Change-Id: I9608c0655d7423df162d0804a6cec0b9ef178fa1 --- M api/ApiGettingStartedGetPages.php M maintenance/dump_redis.php M maintenance/generate_config.php M maintenance/populate_categories.php M tests/phpunit/TaskRecommendationsExperimentV1Test.php 5 files changed, 47 insertions(+), 48 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/api/ApiGettingStartedGetPages.php b/api/ApiGettingStartedGetPages.php index edcb095..338559e 100644 --- a/api/ApiGettingStartedGetPages.php +++ b/api/ApiGettingStartedGetPages.php @@ -16,9 +16,9 @@ public function execute() { $result = $this->getResult(); - $data = array( - 'titles' => array() - ); + $data = [ + 'titles' => [] + ]; $titles = $this->getArticles(); @@ -75,13 +75,13 @@ $attempts = 0; $offset = 0; $isRandomized = $suggester->isRandomized(); - $filteredTitles = array(); + $filteredTitles = []; do { $unfilteredTitles = $suggester->getArticles( $numWanted - $totalResultCount, $offset ); $newFilteredTitles = array_filter( $unfilteredTitles, - array( $pageFilter, 'isAllowedPage' ) + [ $pageFilter, 'isAllowedPage' ] ); $newFilteredTitles = array_udiff( $newFilteredTitles, $filteredTitles, function ( $t1, $t2 ) { @@ -113,44 +113,44 @@ } public function getDescription() { - return array( + return [ 'This API is for getting a list of one or more pages related to a ' . 'particular GettingStarted task.', - ); + ]; } public function getParamDescription() { - return array( + return [ 'taskname' => 'Task name, generally either "copyedit" (copy-editing suggestions) or ' . ' "morelike" (pages similar to the base page/excluded title)', 'excludedtitle' => 'Full title of a page to exclude from the list; also used as the ' . 'base title for recommendations based on a given page', 'count' => 'Requested count; will attempt to fetch this exact number, but may fetch ' . 'fewer if no more are found after multiple attempts', - ); + ]; } public function getAllowedParams() { - return array( - 'taskname' => array( + return [ + 'taskname' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'excludedtitle' => array( + ], + 'excludedtitle' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => false, - ), - 'count' => array( + ], + 'count' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_REQUIRED => true, - ), - ); + ], + ]; } public function getExamples() { - return array( + return [ 'api.php?action=query&list=gettingstartedgetpages&gsgptaskname=copyedit' . '&gsgpexcludedtitle=Earth&gsgpcount=1', - ); + ]; } } diff --git a/maintenance/dump_redis.php b/maintenance/dump_redis.php index fdbe4a9..214de53 100755 --- a/maintenance/dump_redis.php +++ b/maintenance/dump_redis.php @@ -16,7 +16,7 @@ */ $IP = getenv( 'MW_INSTALL_PATH' ); -if( $IP === false ) { +if ( $IP === false ) { $IP = __DIR__ . '/../../..'; } diff --git a/maintenance/generate_config.php b/maintenance/generate_config.php index bb1cd5f..588095e 100644 --- a/maintenance/generate_config.php +++ b/maintenance/generate_config.php @@ -14,7 +14,7 @@ use Title; $IP = getenv( 'MW_INSTALL_PATH' ); -if( $IP === false ) { +if ( $IP === false ) { $IP = __DIR__ . '/../../..'; } @@ -33,9 +33,9 @@ * (see $wgGettingStartedTasks) and the value is the QID of a * Wikidata entity. */ - private $qidsForTaskTypes = array( + private $qidsForTaskTypes = [ 'copyedit' => 'Q9125773', // Category:Wikipedia articles needing copy edit - ); + ]; public function __construct() { $this->mDescription = 'Generates files that contain the values for the ' . @@ -64,12 +64,12 @@ } private function generateWgGettingStartedCategoriesForTaskTypesConfig( $dbnames ) { - $config = array(); + $config = []; foreach ( $this->qidsForTaskTypes as $task => $qid ) { $sitelinks = $this->getSitelinksByQID( $qid, $dbnames ); foreach ( $sitelinks as $dbname => $categoryName ) { if ( !isset( $config[ $dbname ] ) ) { - $config[ $dbname ] = array(); + $config[ $dbname ] = []; } $config[ $dbname ][ $task ] = $categoryName; @@ -85,10 +85,10 @@ // NOTE (phuedx, 2014-05-14): PageFilter::getExcludedCategories // expects wgGettingStartedExcludedCategories to be an array of // strings, not a string. - $config = array(); + $config = []; foreach ( $sitelinks as $dbname => $category ) { - $config[ $dbname ] = array( $category ); + $config[ $dbname ] = [ $category ]; } $this->writeConfig( $config, self::WG_GETTING_STARTED_EXCLUDED_CATEGORIES_FILE ); @@ -107,7 +107,7 @@ $responseBodyRaw = file_get_contents( $url ); $responseBody = json_decode( $responseBodyRaw, true ); $entity = $responseBody[ 'entities' ][ $qid ]; - $result = array(); + $result = []; foreach ( $entity[ 'sitelinks' ] as $dbname => $sitelink ) { if ( !$dbnames || in_array( $dbname, $dbnames ) ) { @@ -120,4 +120,4 @@ } $maintClass = 'GettingStarted\GenerateConfig'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/populate_categories.php b/maintenance/populate_categories.php index 1c2a36f..d64f01a 100644 --- a/maintenance/populate_categories.php +++ b/maintenance/populate_categories.php @@ -11,7 +11,7 @@ */ $IP = getenv( 'MW_INSTALL_PATH' ); -if( $IP === false ) { +if ( $IP === false ) { $IP = __DIR__ . '/../../..'; } @@ -30,32 +30,31 @@ $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - array( 'page', 'categorylinks' ), - array( 'page_id' ), - array( + [ 'page', 'categorylinks' ], + [ 'page_id' ], + [ 'cl_from = page_id', 'cl_to' => $category->getName(), 'page_is_redirect' => 0, 'page_namespace' => NS_MAIN, - ), + ], __FUNCTION__ ); - $pages = array(); - foreach( $res as $row ) { + $pages = []; + foreach ( $res as $row ) { $pages[] = $row->page_id; } if ( !count( $pages ) ) { return 0; } - $redis = $this->mClient->multi( \Redis::PIPELINE ); $batches = array_chunk( $pages, 100 ); - foreach( $batches as $batch ) { + foreach ( $batches as $batch ) { array_unshift( $batch, $key ); - call_user_func_array( array( $redis, 'sAdd' ), $batch ); + call_user_func_array( [ $redis, 'sAdd' ], $batch ); } return $redis->exec() ? count( $pages ) : 0; } @@ -66,7 +65,7 @@ $this->error( 'Failed to get Redis connection. Exiting.', 1 ); } - foreach( RedisCategorySync::getCategories() as $catName ) { + foreach ( RedisCategorySync::getCategories() as $catName ) { echo "Populating category '${catName}' ...\n"; $cat = Category::newFromName( $catName ); $count = $this->populateCategory( $cat ); @@ -76,4 +75,4 @@ } $maintClass = 'GettingStarted\PopulateCategories'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/tests/phpunit/TaskRecommendationsExperimentV1Test.php b/tests/phpunit/TaskRecommendationsExperimentV1Test.php index ddd5dea..3d4e4a7 100644 --- a/tests/phpunit/TaskRecommendationsExperimentV1Test.php +++ b/tests/phpunit/TaskRecommendationsExperimentV1Test.php @@ -61,16 +61,16 @@ } public static function bucketingDataProvider() { - return array( - array( + return [ + [ 1, // ID true, // Should see post-edit notification false, // Shouldn't see flyout - ), - array( 2, false, true ), - array( 3, true, true ), - array( 4, false, false ), - ); + ], + [ 2, false, true ], + [ 3, true, true ], + [ 4, false, false ], + ]; } /** -- To view, visit https://gerrit.wikimedia.org/r/357392 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9608c0655d7423df162d0804a6cec0b9ef178fa1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GettingStarted Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Phuedx <samsm...@wikimedia.org> Gerrit-Reviewer: Swalling <steven.wall...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits