[MediaWiki-commits] [Gerrit] thank-you-edit: Only call User::getEditCount() once - change (mediawiki...Echo)
jenkins-bot has submitted this change and it was merged. Change subject: thank-you-edit: Only call User::getEditCount() once .. thank-you-edit: Only call User::getEditCount() once And rename $editCount to $thresholdCount for clarity. Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c (cherry picked from commit 51dd4fd10980bc883f4dd68d96c1aab7562ce375) --- M Hooks.php 1 file changed, 9 insertions(+), 8 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/Hooks.php b/Hooks.php index 59ada97..4c19644 100644 --- a/Hooks.php +++ b/Hooks.php @@ -459,13 +459,14 @@ $thresholds = [ 1, 10, 100, 1000, 1, 10, 100 ]; if ( $user->isLoggedIn() && $status->value['revision'] ) { // This edit hasn't been added to the edit count yet - $editCount = $user->getEditCount() + 1; - if ( in_array( $editCount, $thresholds ) ) { + $thresholdCount = $user->getEditCount() + 1; + if ( in_array( $thresholdCount, $thresholds ) ) { $id = $user->getId(); - DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $editCount ) { + DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $thresholdCount ) { // Fresh User object $user = User::newFromId( $id ); - if ( $user->getEditCount() !== $editCount ) { + $userEditCount = $user->getEditCount(); + if ( $userEditCount !== $thresholdCount ) { // Race condition with multiple simultaneous requests, skip LoggerFactory::getInstance( 'Echo' )->debug( 'thank-you-edit race condition detected: {user} (id: {id}) should ' . @@ -473,8 +474,8 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'expectedCount' => $editCount, - 'actualCount' => $user->getEditCount(), + 'expectedCount' => $thresholdCount, + 'actualCount' => $userEditCount, ) ); return; @@ -484,7 +485,7 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'count' => $editCount, + 'count' => $thresholdCount, ) ); EchoEvent::create( array( @@ -494,7 +495,7 @@ // Edit threshold notifications are sent to the agent 'extra' => array( 'notifyAgent' => true, - 'editCount' => $editCount, + 'thresholdCount' => $thresholdCount, ) ) ); -- To view, visit https://gerrit.wikimedia.org/r/276556 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: wmf/1.27.0-wmf.16 Gerrit-Owner: Catrope Gerrit-Reviewer: Catrope Gerrit-Reviewer: Legoktm Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] thank-you-edit: Only call User::getEditCount() once - change (mediawiki...Echo)
Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/276556 Change subject: thank-you-edit: Only call User::getEditCount() once .. thank-you-edit: Only call User::getEditCount() once And rename $editCount to $thresholdCount for clarity. Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c (cherry picked from commit 51dd4fd10980bc883f4dd68d96c1aab7562ce375) --- M Hooks.php 1 file changed, 9 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/56/276556/1 diff --git a/Hooks.php b/Hooks.php index 59ada97..4c19644 100644 --- a/Hooks.php +++ b/Hooks.php @@ -459,13 +459,14 @@ $thresholds = [ 1, 10, 100, 1000, 1, 10, 100 ]; if ( $user->isLoggedIn() && $status->value['revision'] ) { // This edit hasn't been added to the edit count yet - $editCount = $user->getEditCount() + 1; - if ( in_array( $editCount, $thresholds ) ) { + $thresholdCount = $user->getEditCount() + 1; + if ( in_array( $thresholdCount, $thresholds ) ) { $id = $user->getId(); - DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $editCount ) { + DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $thresholdCount ) { // Fresh User object $user = User::newFromId( $id ); - if ( $user->getEditCount() !== $editCount ) { + $userEditCount = $user->getEditCount(); + if ( $userEditCount !== $thresholdCount ) { // Race condition with multiple simultaneous requests, skip LoggerFactory::getInstance( 'Echo' )->debug( 'thank-you-edit race condition detected: {user} (id: {id}) should ' . @@ -473,8 +474,8 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'expectedCount' => $editCount, - 'actualCount' => $user->getEditCount(), + 'expectedCount' => $thresholdCount, + 'actualCount' => $userEditCount, ) ); return; @@ -484,7 +485,7 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'count' => $editCount, + 'count' => $thresholdCount, ) ); EchoEvent::create( array( @@ -494,7 +495,7 @@ // Edit threshold notifications are sent to the agent 'extra' => array( 'notifyAgent' => true, - 'editCount' => $editCount, + 'thresholdCount' => $thresholdCount, ) ) ); -- To view, visit https://gerrit.wikimedia.org/r/276556 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: wmf/1.27.0-wmf.16 Gerrit-Owner: Catrope Gerrit-Reviewer: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] thank-you-edit: Only call User::getEditCount() once - change (mediawiki...Echo)
jenkins-bot has submitted this change and it was merged. Change subject: thank-you-edit: Only call User::getEditCount() once .. thank-you-edit: Only call User::getEditCount() once And rename $editCount to $thresholdCount for clarity. Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c --- M Hooks.php 1 file changed, 9 insertions(+), 8 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/Hooks.php b/Hooks.php index 59ada97..4c19644 100644 --- a/Hooks.php +++ b/Hooks.php @@ -459,13 +459,14 @@ $thresholds = [ 1, 10, 100, 1000, 1, 10, 100 ]; if ( $user->isLoggedIn() && $status->value['revision'] ) { // This edit hasn't been added to the edit count yet - $editCount = $user->getEditCount() + 1; - if ( in_array( $editCount, $thresholds ) ) { + $thresholdCount = $user->getEditCount() + 1; + if ( in_array( $thresholdCount, $thresholds ) ) { $id = $user->getId(); - DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $editCount ) { + DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $thresholdCount ) { // Fresh User object $user = User::newFromId( $id ); - if ( $user->getEditCount() !== $editCount ) { + $userEditCount = $user->getEditCount(); + if ( $userEditCount !== $thresholdCount ) { // Race condition with multiple simultaneous requests, skip LoggerFactory::getInstance( 'Echo' )->debug( 'thank-you-edit race condition detected: {user} (id: {id}) should ' . @@ -473,8 +474,8 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'expectedCount' => $editCount, - 'actualCount' => $user->getEditCount(), + 'expectedCount' => $thresholdCount, + 'actualCount' => $userEditCount, ) ); return; @@ -484,7 +485,7 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'count' => $editCount, + 'count' => $thresholdCount, ) ); EchoEvent::create( array( @@ -494,7 +495,7 @@ // Edit threshold notifications are sent to the agent 'extra' => array( 'notifyAgent' => true, - 'editCount' => $editCount, + 'thresholdCount' => $thresholdCount, ) ) ); -- To view, visit https://gerrit.wikimedia.org/r/276080 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Legoktm Gerrit-Reviewer: Catrope Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] thank-you-edit: Only call User::getEditCount() once - change (mediawiki...Echo)
Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/276080 Change subject: thank-you-edit: Only call User::getEditCount() once .. thank-you-edit: Only call User::getEditCount() once And rename $editCount to $thresholdCount for clarity. Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c --- M Hooks.php 1 file changed, 9 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo refs/changes/80/276080/1 diff --git a/Hooks.php b/Hooks.php index 59ada97..4c19644 100644 --- a/Hooks.php +++ b/Hooks.php @@ -459,13 +459,14 @@ $thresholds = [ 1, 10, 100, 1000, 1, 10, 100 ]; if ( $user->isLoggedIn() && $status->value['revision'] ) { // This edit hasn't been added to the edit count yet - $editCount = $user->getEditCount() + 1; - if ( in_array( $editCount, $thresholds ) ) { + $thresholdCount = $user->getEditCount() + 1; + if ( in_array( $thresholdCount, $thresholds ) ) { $id = $user->getId(); - DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $editCount ) { + DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $thresholdCount ) { // Fresh User object $user = User::newFromId( $id ); - if ( $user->getEditCount() !== $editCount ) { + $userEditCount = $user->getEditCount(); + if ( $userEditCount !== $thresholdCount ) { // Race condition with multiple simultaneous requests, skip LoggerFactory::getInstance( 'Echo' )->debug( 'thank-you-edit race condition detected: {user} (id: {id}) should ' . @@ -473,8 +474,8 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'expectedCount' => $editCount, - 'actualCount' => $user->getEditCount(), + 'expectedCount' => $thresholdCount, + 'actualCount' => $userEditCount, ) ); return; @@ -484,7 +485,7 @@ array( 'user' => $user->getName(), 'id' => $user->getId(), - 'count' => $editCount, + 'count' => $thresholdCount, ) ); EchoEvent::create( array( @@ -494,7 +495,7 @@ // Edit threshold notifications are sent to the agent 'extra' => array( 'notifyAgent' => true, - 'editCount' => $editCount, + 'thresholdCount' => $thresholdCount, ) ) ); -- To view, visit https://gerrit.wikimedia.org/r/276080 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I115b2dfabf472c855c186d05fa4e31aa7c9c3d6c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Legoktm ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits