jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/369808 )
Change subject: phpcs for refresh-dblist ...................................................................... phpcs for refresh-dblist Change-Id: Ida8f517e6f8071cbae5eae13edbe8494afb7e8a3 --- M refresh-dblist 1 file changed, 45 insertions(+), 42 deletions(-) Approvals: Krinkle: Looks good to me, but someone else must approve Reedy: Looks good to me, approved jenkins-bot: Verified Jforrester: Looks good to me, but someone else must approve diff --git a/refresh-dblist b/refresh-dblist index 6bdff17..333b675 100755 --- a/refresh-dblist +++ b/refresh-dblist @@ -30,25 +30,25 @@ s7.dblist */ -require_once( __DIR__ . '/multiversion/MWRealm.php' ); -require_once( __DIR__ . '/multiversion/defines.php' ); +require_once __DIR__ . '/multiversion/MWRealm.php'; +require_once __DIR__ . '/multiversion/defines.php'; $base = MEDIAWIKI_STAGING_DIR; $defaultCluster = 's3'; -$clusterOverrides = loadClusterList(getRealmSpecificFilename( MEDIAWIKI_STAGING_DIR . '/wmf-config/db.php')); -$clusterAssignments = array(); +$clusterOverrides = loadClusterList( getRealmSpecificFilename( MEDIAWIKI_STAGING_DIR . '/wmf-config/db.php' ) ); +$clusterAssignments = []; $dbList = $wmfRealm === 'labs' ? 'all-labs' : 'all'; $all = MWWikiversions::readDbListFile( $dbList ); -listOut('all', $all, false); -printf("%d wikis listed in " . basename(getRealmSpecificFilename(MEDIAWIKI_DBLIST_DIR . "/all.dblist")) . "...\n", count($all)); +listOut( 'all', $all, false ); +printf( "%d wikis listed in " . basename(getRealmSpecificFilename( MEDIAWIKI_DBLIST_DIR . "/all.dblist" ) ) . "...\n", count( $all ) ); $special = MWWikiversions::readDbListFile( 'special' ); -listOut('special', $special, false); -printf("%d special wikis to be exempted from wikipedia group...\n", count($special)); +listOut( 'special', $special, false ); +printf( "%d special wikis to be exempted from wikipedia group...\n", count( $special ) ); -$suffixes = array( +$suffixes = [ "wiki" => "wikipedia", "wikinews" => "wikinews", "wikibooks" => "wikibooks", @@ -57,81 +57,84 @@ "wiktionary" => "wiktionary", "wikimedia" => "wikimedia", "wikiversity" => "wikiversity", - "wikivoyage" => "wikivoyage" ); + "wikivoyage" => "wikivoyage" +]; -$groups = array(); -$specialMatch = array(); +$groups = []; +$specialMatch = []; -foreach ($all as $wiki) { - if (isset($clusterOverrides[$wiki])) { +foreach ( $all as $wiki ) { + if ( isset( $clusterOverrides[$wiki] ) ) { $cluster = $clusterOverrides[$wiki]; } else { $cluster = $defaultCluster; } $clusterAssignments[$cluster][] = $wiki; - if (in_array($wiki, $special)) { + if ( in_array( $wiki, $special ) ) { $specialMatch[] = $wiki; continue; } - foreach ($suffixes as $suffix => $group) { - if (substr($wiki, -strlen($suffix)) == $suffix) { + foreach ( $suffixes as $suffix => $group ) { + if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) { $groups[$group][] = $wiki; continue 2; } } - printf("Warning: wiki '%s' matches no known group.\n", $wiki); + printf( "Warning: wiki '%s' matches no known group.\n", $wiki ); } -if (count($special) != count($specialMatch)) { - printf("Warning: expected %d special wikis, matched %d.\n", - count($special), count($specialMatch)); +if ( count( $special ) != count( $specialMatch ) ) { + printf( "Warning: expected %d special wikis, matched %d.\n", + count( $special ), + count( $specialMatch ) + ); } -foreach ($groups as $group => $list) { - listOut($group, $list); +foreach ( $groups as $group => $list ) { + listOut( $group, $list ); } echo "Writing out db cluster assignments...\n"; -foreach ($clusterAssignments as $cluster => $list) { - listOut($cluster, $list); +foreach ( $clusterAssignments as $cluster => $list ) { + listOut( $cluster, $list ); } echo "Done.\n"; -function loadClusterList($file) { +function loadClusterList( $file ) { $wgDBname = $wgDBuser = $wgDBpassword = ''; include( $file ); return $wgLBFactoryConf['sectionsByDB']; } -function listOut($group, $list, $print = true) { +function listOut( $group, $list, $print = true ) { global $base; - $filename = getRealmSpecificFilename(MEDIAWIKI_DBLIST_DIR . "/$group.dblist"); + $filename = getRealmSpecificFilename( MEDIAWIKI_DBLIST_DIR . "/$group.dblist" ); if ( $print ) { - printf("Listing %d wikis in %s...\n", count($list), $filename); + printf( "Listing %d wikis in %s...\n", count( $list ), $filename ); } - $out = fopen("$filename.new", "xt"); - if ($out) { - sort($list); - foreach ($list as $wiki) { - fwrite($out, "$wiki\n"); + $out = fopen( "$filename.new", "xt" ); + if ( $out ) { + sort( $list ); + foreach ( $list as $wiki ) { + fwrite( $out, "$wiki\n" ); } - fclose($out); + fclose( $out ); - if (file_exists("$filename.bak")) { - unlink("$filename.bak"); + if ( file_exists( "$filename.bak" ) ) { + unlink( "$filename.bak" ); } - if (file_exists($filename)) { - rename($filename, "$filename.bak"); + if ( file_exists( $filename ) ) { + rename( $filename, "$filename.bak" ); } - rename("$filename.new", $filename); - if (file_exists("$filename.bak")) { - unlink("$filename.bak"); + rename( "$filename.new", $filename ); + if ( file_exists( "$filename.bak" ) ) { + unlink( "$filename.bak" ); } } } -- To view, visit https://gerrit.wikimedia.org/r/369808 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ida8f517e6f8071cbae5eae13edbe8494afb7e8a3 Gerrit-PatchSet: 3 Gerrit-Project: operations/mediawiki-config Gerrit-Branch: master Gerrit-Owner: Reedy <re...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits