We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 482faf66 authored by Evan Prodromou's avatar Evan Prodromou

don't try to get to database at initialize time

parent 642adc3b
......@@ -49,32 +49,26 @@ class BlacklistPlugin extends Plugin
public $urls = array();
public $canAdmin = true;
private $_nicknamePatterns = array();
private $_urlPatterns = array();
/**
* Initialize the plugin
*
* @return void
*/
function initialize()
function _getNicknamePatterns()
{
$confNicknames = $this->_configArray('blacklist', 'nicknames');
$dbNicknames = Nickname_blacklist::getPatterns();
$this->_nicknamePatterns = array_merge($this->nicknames,
$confNicknames,
$dbNicknames);
return array_merge($this->nicknames,
$confNicknames,
$dbNicknames);
}
function _getUrlPatterns()
{
$confURLs = $this->_configArray('blacklist', 'urls');
$dbURLs = Homepage_blacklist::getPatterns();
$this->_urlPatterns = array_merge($this->urls,
$confURLs,
$dbURLs);
return array_merge($this->urls,
$confURLs,
$dbURLs);
}
/**
......@@ -265,7 +259,9 @@ class BlacklistPlugin extends Plugin
private function _checkUrl($url)
{
foreach ($this->_urlPatterns as $pattern) {
$patterns = $this->_getUrlPatterns();
foreach ($patterns as $pattern) {
if (preg_match("/$pattern/", $url)) {
return false;
}
......@@ -286,7 +282,9 @@ class BlacklistPlugin extends Plugin
private function _checkNickname($nickname)
{
foreach ($this->_nicknamePatterns as $pattern) {
$patterns = $this->_getNicknamePatterns();
foreach ($patterns as $pattern) {
if (preg_match("/$pattern/", $nickname)) {
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment