From 0909094e01f25496fb661945c4dd4532954157d3 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 19 Jun 2008 03:14:34 +0000 Subject: [PATCH] And now SpamBlacklist checks the edit summary field. --- SpamBlacklist.php | 8 ++++---- SpamBlacklist_body.php | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/SpamBlacklist.php b/SpamBlacklist.php index 15ebe81d..414bce8f 100644 --- a/SpamBlacklist.php +++ b/SpamBlacklist.php @@ -72,18 +72,18 @@ function wfSpamBlacklistObject() { /** * Hook function for $wgFilterCallback */ -function wfSpamBlacklistFilter( &$title, $text, $section ) { +function wfSpamBlacklistFilter( &$title, $text, $section, &$hookErr, $editSummary ) { $spamObj = wfSpamBlacklistObject(); - return $spamObj->filter( $title, $text, $section ); + return $spamObj->filter( $title, $text, $section, $editSummary ); } /** * Hook function for EditFilterMerged, replaces wfSpamBlacklistFilter */ -function wfSpamBlacklistFilterMerged( $editPage, $text ) { +function wfSpamBlacklistFilterMerged( $editPage, $text, &$hookErr, $editSummary ) { $spamObj = wfSpamBlacklistObject(); $title = $editPage->mArticle->getTitle(); - $ret = $spamObj->filter( $title, $text, '', $editPage ); + $ret = $spamObj->filter( $title, $text, '', $editPage, $editSummary ); // Return convention for hooks is the inverse of $wgFilterCallback return !$ret; } diff --git a/SpamBlacklist_body.php b/SpamBlacklist_body.php index 6e455068..f494ba35 100644 --- a/SpamBlacklist_body.php +++ b/SpamBlacklist_body.php @@ -185,10 +185,11 @@ class SpamBlacklist { * @param string $text Text of section, or entire text if $editPage!=false * @param string $section Section number or name * @param EditPage $editPage EditPage if EditFilterMerged was called, false otherwise + * @param EditSummary $editSummary Edit summary if one exists, some people use urls there too * @return True if the edit should not be allowed, false otherwise * If the return value is true, an error will have been sent to $wgOut */ - function filter( &$title, $text, $section, $editPage = false ) { + function filter( &$title, $text, $section, $editPage = false, $editsummary = '' ) { global $wgArticle, $wgVersion, $wgOut, $wgParser, $wgUser; $fname = 'wfSpamBlacklistFilter'; @@ -226,6 +227,9 @@ class SpamBlacklist { $oldLinks = $this->getCurrentLinks( $title ); $addedLinks = array_diff( $newLinks, $oldLinks ); + // We add the edit summary if one exists + if ( !empty( $editsummary ) ) $addedLinks[] = $editsummary; + wfDebugLog( 'SpamBlacklist', "Old URLs: " . implode( ', ', $oldLinks ) ); wfDebugLog( 'SpamBlacklist', "New URLs: " . implode( ', ', $newLinks ) ); wfDebugLog( 'SpamBlacklist', "Added URLs: " . implode( ', ', $addedLinks ) );