Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/295465

Change subject: Fix bugs in Schema:ExternalLinksChange code
......................................................................

Fix bugs in Schema:ExternalLinksChange code

* Have SpamBlacklist::doLogging() actually run
* Bump schema ID so userId property is an integer
* Don't try logging URLs that were unable to be parsed
* Make sure path/query/fragment are always strings

Bug: T115119
Change-Id: Ia81037e8939dd547f00e79c169fa84ca0a7b917e
---
M SpamBlacklistHooks.php
M SpamBlacklist_body.php
2 files changed, 13 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SpamBlacklist 
refs/changes/65/295465/1

diff --git a/SpamBlacklistHooks.php b/SpamBlacklistHooks.php
index e7df36c..18aa62f 100644
--- a/SpamBlacklistHooks.php
+++ b/SpamBlacklistHooks.php
@@ -252,6 +252,11 @@
                Status $status,
                $baseRevId
        ) {
+               if ( $revision ) {
+                       BaseBlacklist::getInstance( 'spam' )
+                               ->doLogging( $user, $wikiPage->getTitle(), 
$revision );
+               }
+
                if ( !BaseBlacklist::isLocalSource( $wikiPage->getTitle() ) ) {
                        return true;
                }
@@ -262,10 +267,6 @@
                        $blacklist->clearCache();
                }
 
-               if ( $revision ) {
-                       BaseBlacklist::getInstance( 'spam' )
-                               ->doLogging( $user, $wikiPage->getTitle(), 
$revision );
-               }
 
                return true;
        }
diff --git a/SpamBlacklist_body.php b/SpamBlacklist_body.php
index b0e94bb..7d18983 100644
--- a/SpamBlacklist_body.php
+++ b/SpamBlacklist_body.php
@@ -177,7 +177,7 @@
                        foreach ( $changes as $change ) {
                                EventLogging::logEvent(
                                        'ExternalLinksChange',
-                                       15573909,
+                                       15716074,
                                        $baseInfo + $change
                                );
                        }
@@ -192,13 +192,17 @@
         */
        private function logUrlChange( $url, $action ) {
                $parsed = wfParseUrl( $url );
+               if ( !isset( $parsed['host'] ) ) {
+                       wfDebugLog( 'SpamBlacklist', "Unable to parse $url" );
+                       return;
+               }
                $info = array(
                        'action' => $action,
                        'protocol' => $parsed['scheme'],
                        'domain' => $parsed['host'],
-                       'path' => $parsed['path'],
-                       'query' => $parsed['query'],
-                       'fragment' => $parsed['fragment'],
+                       'path' => $parsed['path'] !== null ? $parsed['path'] : 
'',
+                       'query' => $parsed['query'] !== null ? $parsed['query'] 
: '',
+                       'fragment' => $parsed['fragment'] !== null ? 
$parsed['fragment'] : '',
                );
 
                $this->urlChangeLog[] = $info;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia81037e8939dd547f00e79c169fa84ca0a7b917e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SpamBlacklist
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

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

Reply via email to