Fix Schema:ExternalLinksChange logging if no links are left on page

If there are no links left on the page, we would avoid invoking the spam
blacklist filtering entirely, to avoid having to do blacklist lookups,
etc. However, since we want link removal data, explicitly check for this
scenario and mark all current links as removals, and avoid invoking the
rest of the spam blacklist code.

Bug: T115119
Change-Id: I0bcd5b55594e38c0508b21db2c45e5136123efa0
This commit is contained in:
Kunal Mehta 2016-09-27 13:12:09 -07:00 committed by Alex Monk
parent c0379a5a72
commit 2cac3f9ecd
2 changed files with 10 additions and 3 deletions

View file

@ -43,9 +43,6 @@ class SpamBlacklistHooks {
if ( preg_match( '/\S(\.[^\s\d]{2,}|[\/@]\S)/', $summary ) ) {
$links[] = $summary;
}
if ( !$links ) {
return true;
}
$spamObj = BaseBlacklist::getInstance( 'spam' );
$matches = $spamObj->filter( $links, $title );

View file

@ -55,6 +55,16 @@ class SpamBlacklist extends BaseBlacklist {
$statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
$cache = ObjectCache::getLocalClusterInstance();
// If there are no new links, and we are logging,
// mark all of the current links as being removed.
if ( !$links && $this->isLoggingEnabled() ) {
$this->logUrlChanges( $this->getCurrentLinks( $title ), [], [] );
}
if ( !$links ) {
return false;
}
sort( $links );
$key = $cache->makeKey(
'blacklist',