Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/285424
Change subject: Fix phpcs warnings
......................................................................
Fix phpcs warnings
Change-Id: Ice5ff0bd25c5e2af522965bf8229e64bce70b593
---
M LoginNotify_body.php
M composer.json
M tests/LoginNotifyTests.php
3 files changed, 26 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LoginNotify
refs/changes/24/285424/1
diff --git a/LoginNotify_body.php b/LoginNotify_body.php
index 9bd1b7c..2b72675 100644
--- a/LoginNotify_body.php
+++ b/LoginNotify_body.php
@@ -56,7 +56,6 @@
$this->log = $log;
}
-
/**
* Get just network part of an IP (assuming /24 or /64)
*
@@ -65,7 +64,7 @@
*/
private function getIPNetwork( $ip ) {
$ip = IP::sanitizeIP( $ip );
- if ( IP::isIPv6( $ip ) ) {
+ if ( IP::isIPv6( $ip ) ) {
// Match against the /64
$subnetRegex =
'/[0-9A-F]+:[0-9A-F]+:[0-9A-F]+:[0-9A-F]+$/i';
} elseif ( IP::isIPv4( $ip ) ) {
@@ -188,13 +187,14 @@
$info = $globalUser->queryAttached();
// already checked the local wiki.
unset( $info[wfWikiId()] );
- usort( $info, function( $a, $b ) {
+ usort( $info,
+ function( $a, $b ) {
// descending order
return $b['editCount'] -
$a['editCount'];
}
);
$count = 0;
- foreach( $info as $wiki => $localInfo ) {
+ foreach ( $info as $wiki => $localInfo ) {
if ( $count > 10 ||
$localInfo['editCount'] < 1 ) {
break;
}
@@ -403,10 +403,11 @@
} else {
$cookieRecords = explode( '.', $cookie );
}
- $newCookie = $this->generateUserCookieRecord( $user->getName()
);
+ $newCookie = $this->generateUserCookieRecord( $user->getName()
);
$maxCookieRecords = $this->config->get(
'LoginNotifyMaxCookieRecords' );
- for( $i = 0; $i < count( $cookieRecords ); $i++ ) {
+ $totalCookieRecord = count( $cookieRecords );
+ for ( $i = 0; $i < $totalCookieRecord; $i++ ) {
if ( !$this->validateCookieRecord( $cookieRecords[$i] )
) {
// Skip invalid or old cookie records.
continue;
@@ -465,7 +466,7 @@
// computer in two years, should probably not consider
it trusted.
return false;
}
- return true;
+ return true;
}
/**
@@ -566,9 +567,9 @@
if ( $count !== null ) {
$extra['count'] = $count;
}
- EchoEvent::create( [
- 'type' => $type,
- 'extra' => $extra,
+ EchoEvent::create( [
+ 'type' => $type,
+ 'extra' => $extra,
'agent' => $user,
] );
}
diff --git a/composer.json b/composer.json
index 5d52161..b0e3e0b 100644
--- a/composer.json
+++ b/composer.json
@@ -1,4 +1,10 @@
{
+ "homepage": "https://www.mediawiki.org/wiki/Extension:LoginNotify",
+ "license": "GPL-2.0+",
+ "name": "mediawiki/loginnotify",
+ "type": "mediawiki-extension",
+ "description": "MediaWiki extension to notify users if someone tries to
login to their account",
+ "license": "MIT",
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2",
"mediawiki/mediawiki-codesniffer": "0.6.0"
diff --git a/tests/LoginNotifyTests.php b/tests/LoginNotifyTests.php
index 9fe5203..ed0a293 100644
--- a/tests/LoginNotifyTests.php
+++ b/tests/LoginNotifyTests.php
@@ -1,6 +1,7 @@
<?php
use \Psr\Log\NullLogger;
+// @codingStandardsIgnoreStart Generic.Files.LineLength
class LoginNotifyTests extends MediaWikiTestCase {
/** @var LoginNotify */
@@ -124,7 +125,7 @@
// Make sure proper normalization happens.
$user2 = User::newFromName( 'Foo__bar' );
$user3 = User::newFromName( 'Somebody' );
-
+
$this->assertEquals(
'global:loginnotify:new:ok2qitd5efi25tzjy2l3el4n57g6l3l',
$this->inst->getKey( $user1, 'new' )
@@ -197,9 +198,12 @@
$expectedNewCookie,
$desc
) {
- list( $actualSeenBefore, $actualNewCookie ) =
$this->inst->checkAndGenerateCookie( $user, $cookie );
+ list( $actualSeenBefore, $actualNewCookie ) =
+ $this->inst->checkAndGenerateCookie( $user, $cookie );
- $this->assertEquals( $expectedSeenBefore, $actualSeenBefore,
"[Seen before] $desc" );
+ $this->assertEquals( $expectedSeenBefore, $actualSeenBefore,
+ "[Seen before] $desc"
+ );
$newCookieParts = explode( '.', $actualNewCookie, 2 );
if ( !isset( $newCookieParts[1] ) ) {
$newCookieParts[1] = '';
@@ -281,7 +285,7 @@
* @dataProvider provideValidateCookieRecord
*/
public function testValidateCookieRecord( $cookie, $expected ) {
- $this->assertEquals($expected,
$this->inst->validateCookieRecord( $cookie ) );
+ $this->assertEquals($expected,
$this->inst->validateCookieRecord( $cookie ) );
}
public function provideValidateCookieRecord() {
@@ -310,3 +314,4 @@
$this->assertFalse( $this->inst->checkUserInCache( $u ) );
}
}
+// @codingStandardsIgnoreEnd
--
To view, visit https://gerrit.wikimedia.org/r/285424
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice5ff0bd25c5e2af522965bf8229e64bce70b593
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits