Krinkle has uploaded a new change for review. https://gerrit.wikimedia.org/r/307908
Change subject: build: Fix phpcs coding style violations ...................................................................... build: Fix phpcs coding style violations Change-Id: I25b85c616d66e0781bba88a6713c7420f2213174 --- M app.php M composer.json M index.php M lb/guc.php M lb/wikicontribs.php M phpcs.xml 6 files changed, 39 insertions(+), 39 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/tools/guc refs/changes/08/307908/1 diff --git a/app.php b/app.php index 6511c22..bca1313 100644 --- a/app.php +++ b/app.php @@ -59,7 +59,6 @@ * @return PDO */ public function getDB($database = 'meta', $clusterNr = 's1.labsdb') { - if (!$clusterNr) { throw new lb_Exception('Invalid DB cluster specification'); } @@ -69,10 +68,9 @@ } $pdo = $this->clusters[$clusterNr]; - // Datenbank auswählen + // Select the right database on this cluster server $m = $pdo->prepare('USE `'.$database.'_p`;'); $m->execute(); - unset($m); return $pdo; } @@ -91,7 +89,6 @@ $first = null; $out = ''; foreach ($this->times as $nr => $data) { - $diff = ($timebefore === null) ? 0.0 : $data[0] - $timebefore; if ($timebefore === null) { $first = $data[0]; @@ -114,13 +111,13 @@ public function parseMwDate($tstime) { // Based on MWTimestamp::setTimestamp for TS_MW $da = array(); - preg_match( '/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D', $tstime, $da ); + preg_match('/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D', $tstime, $da); - $da = array_map( 'intval', $da ); + $da = array_map('intval', $da); $da[0] = '%04d-%02d-%02dT%02d:%02d:%02d.00+00:00'; - $strtime = call_user_func_array( 'sprintf', $da ); + $strtime = call_user_func_array('sprintf', $da); - return new DateTime( $strtime, new DateTimeZone( 'GMT' ) ); + return new DateTime($strtime, new DateTimeZone('GMT')); } /** @@ -171,7 +168,7 @@ $section = trim(preg_replace('/[ _]+/', ' ', $section)); $link = '<a href="' . htmlspecialchars( "$server/w/index.php?title=" . htmlspecialchars(_wpurlencode($page)) . "#$section" - ) . '">→</a>'; + ) . '">→</a>'; if ($isPost) { // mw-msg: colon-sep @@ -184,8 +181,8 @@ $html = $link . "\xE2\x80\x8E" . '<span dir="auto">' . $auto; $append .= '</span>'; return $html; - }, - $comment + }, + $comment ); $comment .= $append; diff --git a/composer.json b/composer.json index 63d3d99..3124f02 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,12 @@ { + "require": { + "php": ">=5.4", + "Krinkle/toollabs-base": "^0.8.0" + }, "require-dev": { - "squizlabs/php_codesniffer": "1.*" + "squizlabs/php_codesniffer": "^2.6.2" }, "scripts": { "test": "phpcs . --standard=phpcs.xml --ignore=vendor/* --extensions=php" - }, - "require": { - "Krinkle/toollabs-base": "^0.8.0" } } diff --git a/index.php b/index.php index 86505c5..5a62b64 100644 --- a/index.php +++ b/index.php @@ -63,13 +63,13 @@ $query['user'] = $data->Username; } // Strip defaults -$query = array_diff_assoc( $query, guc::getDefaultOptions() ); -$data->Permalink = './' . ( !$query ? '' : '?' . http_build_query( $query ) ); +$query = array_diff_assoc($query, guc::getDefaultOptions()); +$data->Permalink = './' . ( !$query ? '' : '?' . http_build_query($query) ); $headRobots = !$robotsPolicy ? '' : - '<meta name="robots" content="' . htmlspecialchars( $robotsPolicy ) . '">'; + '<meta name="robots" content="' . htmlspecialchars($robotsPolicy) . '">'; $headCanonical = !$canonicalUrl ? '' : - '<link rel="canonical" href="' . htmlspecialchars( $canonicalUrl ) . '">'; + '<link rel="canonical" href="' . htmlspecialchars($canonicalUrl) . '">'; ?> <!DOCTYPE html> @@ -79,8 +79,12 @@ <link rel="stylesheet" href="resources/style.css"> <title>Global user contributions</title> <?php - if ($headRobots) print "$headRobots\n"; - if ($headCanonical) print "$headCanonical\n"; +if ($headRobots) { +print "$headRobots\n"; +} +if ($headCanonical) { +print "$headCanonical\n"; +} ?><script> var data = <?php print json_encode($data); ?>; </script> @@ -93,14 +97,14 @@ </div> <form action="./" method="POST" class="searchField" id="searchForm"> <p><label>IP address or username: <input name="user" value="<?php - if ($data->Username) { - print htmlspecialchars($data->Username); - } + if ($data->Username) { + print htmlspecialchars($data->Username); + } ?>"></label></p> <p><label>Activate prefix pattern search: <input name="isPrefixPattern" type="checkbox" value="1"<?php - if ($data->options['isPrefixPattern']) { - print ' checked'; - } + if ($data->options['isPrefixPattern']) { + print ' checked'; + } ?>></label></p> <p><label>Results from: <?php $resultSelect = new HtmlSelect([ @@ -108,8 +112,8 @@ 'rc' => 'Recent changes (last 30 days)', 'hr' => 'Last hour only' ]); - $resultSelect->setDefault( $data->options['src'] ); - $resultSelect->setName( 'src' ); + $resultSelect->setDefault($data->options['src']); + $resultSelect->setName('src'); print $resultSelect->getHTML(); ?></label></p> <input type="submit" value="Search" class="submitbutton" id="submitButton"> diff --git a/lb/guc.php b/lb/guc.php index 7cdfca9..305562f 100644 --- a/lb/guc.php +++ b/lb/guc.php @@ -164,7 +164,7 @@ * @param array $wikis * @return array */ - private function _getWikisWithContribs(Array $wikis) { + private function _getWikisWithContribs(array $wikis) { $this->app->aTP('Query all wikis for matching revisions'); $wikisWithEditcount = array(); @@ -258,7 +258,6 @@ $statement->bindParam(':user', $this->user); $statement->execute(); $rows = $statement->fetchAll(PDO::FETCH_OBJ); - unset($statement); if (!$rows) { return false; } @@ -275,7 +274,7 @@ /** * Add IP address to hostname map (if not already). */ - private function addIP( $ip ) { + private function addIP($ip) { if (!isset($this->hostnames[$ip])) { $hostname = @gethostbyaddr($ip); $this->hostnames[$ip] = $hostname ?: false; diff --git a/lb/wikicontribs.php b/lb/wikicontribs.php index 308f800..a32a589 100644 --- a/lb/wikicontribs.php +++ b/lb/wikicontribs.php @@ -68,7 +68,8 @@ if ($this->isIp !== true) { $this->app->aTP('Query user data for ' . $wiki->domain); // Get user data - $statement = $this->app->getDB($wiki->dbname, $wiki->slice)->prepare("SELECT + $statement = $this->app->getDB($wiki->dbname, $wiki->slice)->prepare( + "SELECT `user_id`, `user_name` FROM `user` @@ -86,7 +87,6 @@ } $statement->execute(); $rows = $statement->fetchAll(PDO::FETCH_OBJ); - unset($statement); // Limit quering of user ids to 10. If it's more than that, make the database // query for contributions like for IP-addresses by using wildcard user_text. @@ -176,9 +176,9 @@ // Ignore RC entries for log events and things like // Wikidata and categorization updates '`rc_type` IN (' . join(',', array_map( - 'intval', - array(self::MW_RC_EDIT, self::MW_RC_NEW) - )) . ')' + 'intval', + array(self::MW_RC_EDIT, self::MW_RC_NEW) + )) . ')' ]; $conds = array_merge($conds, $extraConds); $sqlCond = implode(' AND ', $conds); @@ -328,7 +328,6 @@ $db->bindParam(':ipaddress', $this->user); $db->execute(); $res = $db->fetchAll(PDO::FETCH_ASSOC); - unset($db); return $res; } @@ -347,7 +346,6 @@ $db->bindParam(':id', $userId); $db->execute(); $res = $db->fetchAll(PDO::FETCH_ASSOC); - unset($db); return $res; } diff --git a/phpcs.xml b/phpcs.xml index 709cfd6..b9da8ff 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -3,6 +3,7 @@ <rule ref="PSR2"> <exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" /> <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" /> + <exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" /> <!-- Buggy for inline php tags in html --> <exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" /> <!-- TODO: --> -- To view, visit https://gerrit.wikimedia.org/r/307908 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I25b85c616d66e0781bba88a6713c7420f2213174 Gerrit-PatchSet: 1 Gerrit-Project: labs/tools/guc Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits