[MediaWiki-commits] [Gerrit] mediawiki...LoginNotify[master]: Use info itself instead of array index

2017-06-09 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/358152 )

Change subject: Use info itself instead of array index
..


Use info itself instead of array index

Also remove unused variable.

Bug: T167354
Change-Id: I543bcf9c1b3c083288294d2f504378ccafb501d9
---
M LoginNotify_body.php
1 file changed, 10 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Kaldari: Looks good to me, approved



diff --git a/LoginNotify_body.php b/LoginNotify_body.php
index 6828422..059b86a 100644
--- a/LoginNotify_body.php
+++ b/LoginNotify_body.php
@@ -191,7 +191,6 @@
// edited the most. We only do top ten, to limit the worst-case 
where the
// user has accounts on 800 wikis.
if ( class_exists( 'CentralAuthUser' ) ) {
-   $wikisByEditCounts = [];
$globalUser = CentralAuthUser::getInstance( $user );
if ( $globalUser->exists() ) {
// This is expensive. However, On WMF wikis, 
probably
@@ -207,17 +206,24 @@
}
);
$count = 0;
-   foreach ( $info as $wiki => $localInfo ) {
+   $total = count( $info );
+   foreach ( $info as $localInfo ) {
+   if ( !isset( $localInfo['id'] ) || 
!isset( $localInfo['wiki'] ) ) {
+   wfDebugLog( 'AdHocDebug', 
"Unexpected user data [$count/$total]: "
+   . print_r( $localInfo, 
true ) );
+   break;
+   }
if ( $count > 10 || 
$localInfo['editCount'] < 1 ) {
break;
}
+   $wiki = $localInfo['wiki'];
try {
$lb = wfGetLB( $wiki );
$dbrLocal = $lb->getConnection( 
DB_SLAVE, [], $wiki );
} catch ( DBConnectionError $ex ) {
// FIXME: sometimes, we get 
garbage wiki names (T167354)
-   wfDebugLog( 'AdHocDebug', 
"Couldn't connect to database $wiki, info: "
-   . json_encode( $info ) 
);
+   wfDebugLog( 'AdHocDebug', 
"Couldn't connect to database $wiki [$count/$total], info: "
+   . print_r( $localInfo, 
true ) );
continue;
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/358152
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I543bcf9c1b3c083288294d2f504378ccafb501d9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: MaxSem 
Gerrit-Reviewer: Kaldari 
Gerrit-Reviewer: Niharika29 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...LoginNotify[master]: Use info itself instead of array index

2017-06-09 Thread MaxSem (Code Review)
MaxSem has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/358152 )

Change subject: Use info itself instead of array index
..

Use info itself instead of array index

Also remove unused variable.

Bug: T167354
Change-Id: I543bcf9c1b3c083288294d2f504378ccafb501d9
---
M LoginNotify_body.php
1 file changed, 9 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LoginNotify 
refs/changes/52/358152/1

diff --git a/LoginNotify_body.php b/LoginNotify_body.php
index 6828422..b41af62 100644
--- a/LoginNotify_body.php
+++ b/LoginNotify_body.php
@@ -191,7 +191,6 @@
// edited the most. We only do top ten, to limit the worst-case 
where the
// user has accounts on 800 wikis.
if ( class_exists( 'CentralAuthUser' ) ) {
-   $wikisByEditCounts = [];
$globalUser = CentralAuthUser::getInstance( $user );
if ( $globalUser->exists() ) {
// This is expensive. However, On WMF wikis, 
probably
@@ -207,17 +206,23 @@
}
);
$count = 0;
-   foreach ( $info as $wiki => $localInfo ) {
+   $total = count( $info );
+   foreach ( $info as $localInfo ) {
+   if ( !isset( $localInfo['id'] ) || 
!isset( $localInfo['wiki'] ) ) {
+   wfDebugLog( 'AdHocDebug', 
"Unexpected user data [$count/$total]: " . print_r( $localInfo, true ) );
+   break;
+   }
if ( $count > 10 || 
$localInfo['editCount'] < 1 ) {
break;
}
+   $wiki = $localInfo['wiki'];
try {
$lb = wfGetLB( $wiki );
$dbrLocal = $lb->getConnection( 
DB_SLAVE, [], $wiki );
} catch ( DBConnectionError $ex ) {
// FIXME: sometimes, we get 
garbage wiki names (T167354)
-   wfDebugLog( 'AdHocDebug', 
"Couldn't connect to database $wiki, info: "
-   . json_encode( $info ) 
);
+   wfDebugLog( 'AdHocDebug', 
"Couldn't connect to database $wiki [$count/$total], info: "
+   . print_r( $localInfo, 
true ) );
continue;
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/358152
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I543bcf9c1b3c083288294d2f504378ccafb501d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: MaxSem 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits