CSteipp has submitted this change and it was merged.
Change subject: Make use of the user_timestamp index in ApiQueryAbuseLog
......................................................................
Make use of the user_timestamp index in ApiQueryAbuseLog
Furthermore sanitize IPs as ::01 == ::1
Change-Id: I91489d17c012004f607bbe571b9a2702afbf3d81
---
M api/ApiQueryAbuseLog.php
1 file changed, 23 insertions(+), 1 deletion(-)
Approvals:
CSteipp: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/api/ApiQueryAbuseLog.php b/api/ApiQueryAbuseLog.php
index 7bb12ee..db77fac 100644
--- a/api/ApiQueryAbuseLog.php
+++ b/api/ApiQueryAbuseLog.php
@@ -105,7 +105,29 @@
$db = $this->getDB();
$notDeletedCond = SpecialAbuseLog::getNotDeletedCond($db);
- $this->addWhereIf( array( 'afl_user_text' => $params['user'] ),
isset( $params['user'] ) );
+ if ( isset( $params['user'] ) ) {
+ $u = User::newFromName( $params['user'] );
+ if ( $u ) {
+ // Username normalisation
+ $params['user'] = $u->getName();
+ $userId = $u->getId();
+ } elseif( IP::isIPAddress( $params['user'] ) ) {
+ // It's an IP, sanitize it
+ $params['user'] = IP::sanitizeIP(
$params['user'] );
+ $userId = 0;
+ }
+
+ if ( isset( $userId ) ) {
+ // Only add the WHERE for user in case it's
either a valid user (but not necessary an existing one) or an IP
+ $this->addWhere(
+ array(
+ 'afl_user' => $userId,
+ 'afl_user_text' =>
$params['user']
+ )
+ );
+ }
+ }
+
$this->addWhereIf( array( 'afl_filter' => $params['filter'] ),
isset( $params['filter'] ) );
$this->addWhereIf( $notDeletedCond,
!SpecialAbuseLog::canSeeHidden( $user ) );
--
To view, visit https://gerrit.wikimedia.org/r/55828
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I91489d17c012004f607bbe571b9a2702afbf3d81
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits