/** * Build a set of regular expressions from a MediaWiki message. * Will be correctly empty if the message isn't present. * * @param $message string * @return array of regular expressions, potentially empty */ static function regexesFromMessage( $message ) { $source = wfMsgForContent( $message ); if( $source && !wfEmptyMsg( $message, $source ) ) { return SpamRegexBatch::regexesFromText( $source ); } else { return array(); } }
function buildSharedBlacklists() { $regexes = array(); $listType = $this->getBlacklistType(); # Load lists wfDebugLog( 'SpamBlacklist', "Constructing $listType blacklist\n" ); foreach ( $this->files as $fileName ) { $matches = array(); if ( preg_match( '/^DB: ([\w-]*) (.*)$/', $fileName, $matches ) ) { $text = $this->getArticleText( $matches[1], $matches[2] ); } elseif ( preg_match( '/^http:\/\//', $fileName ) ) { $text = $this->getHttpText( $fileName ); } else { $text = file_get_contents( $fileName ); wfDebugLog( 'SpamBlacklist', "got from file $fileName\n" ); } // Build a separate batch of regexes from each source. // While in theory we could squeeze a little efficiency // out of combining multiple sources in one regex, if // there's a bad line in one of them we'll gain more // from only having to break that set into smaller pieces. $regexes = array_merge( $regexes, SpamRegexBatch::regexesFromText( $text, $fileName ) ); } return $regexes; }
/** * Build a set of regular expressions from a MediaWiki message. * Will be correctly empty if the message isn't present. * * @param $message string * @param $blacklist BaseBlacklist * @return array of regular expressions, potentially empty */ static function regexesFromMessage($message, BaseBlacklist $blacklist) { $source = wfMessage($message)->inContentLanguage(); if (!$source->isDisabled()) { return SpamRegexBatch::regexesFromText($source->plain(), $blacklist); } else { return array(); } }