bayes 1.1: Fix table creation for recycler and upgrades

This commit is contained in:
onli 2020-08-19 00:11:14 +02:00
parent a2878bd3be
commit bdbdb5d35c
2 changed files with 11 additions and 9 deletions

View file

@ -1,3 +1,8 @@
1.1:
* Fix creation of needed b8_wordlist table also when upgrading
from an older version
* Fix recycler table creation
1.0: 1.0:
* Update from the forked old b8 version to a current * Update from the forked old b8 version to a current
version of that library version of that library

View file

@ -19,7 +19,7 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
$this->title = PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME; $this->title = PLUGIN_EVENT_SPAMBLOCK_BAYES_NAME;
$propbag->add ( 'description', PLUGIN_EVENT_SPAMBLOCK_BAYES_DESC); $propbag->add ( 'description', PLUGIN_EVENT_SPAMBLOCK_BAYES_DESC);
$propbag->add ( 'name', $this->title); $propbag->add ( 'name', $this->title);
$propbag->add ( 'version', '1.0' ); $propbag->add ( 'version', '1.1' );
$propbag->add ( 'event_hooks', array ('frontend_saveComment' => true, $propbag->add ( 'event_hooks', array ('frontend_saveComment' => true,
'backend_comments_top' => true, 'backend_comments_top' => true,
'external_plugin' => true, 'external_plugin' => true,
@ -89,14 +89,6 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
$title = $this->title; $title = $this->title;
} }
function install() {
$this->setupDB();
}
function upgrade() {
$this->setupDB();
}
function setupDB() { function setupDB() {
global $serendipity; global $serendipity;
# b8 needs to one table for the tokens # b8 needs to one table for the tokens
@ -120,6 +112,7 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
{$serendipity['dbPrefix']}spamblock_bayes_recycler {$serendipity['dbPrefix']}spamblock_bayes_recycler
LIKE LIKE
{$serendipity['dbPrefix']}comments"; {$serendipity['dbPrefix']}comments";
serendipity_db_schema_import($sql);
break; break;
case 'sqlite': case 'sqlite':
case 'sqlite3': case 'sqlite3':
@ -140,12 +133,14 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
if (strpos("sql", "NOT EXISTS") === false) { if (strpos("sql", "NOT EXISTS") === false) {
$sql = str_replace("CREATE TABLE", "CREATE TABLE IF NOT EXISTS", $sql); $sql = str_replace("CREATE TABLE", "CREATE TABLE IF NOT EXISTS", $sql);
} }
serendipity_db_schema_import($sql);
break; break;
default: default:
$sql = "CREATE TABLE IF NOT EXISTS $sql = "CREATE TABLE IF NOT EXISTS
{$serendipity['dbPrefix']}spamblock_bayes_recycler {$serendipity['dbPrefix']}spamblock_bayes_recycler
as SELECT * FROM as SELECT * FROM
{$serendipity['dbPrefix']}comments ORDER BY id LIMIT 1 WITH NO DATA"; {$serendipity['dbPrefix']}comments ORDER BY id LIMIT 1 WITH NO DATA";
serendipity_db_schema_import($sql);
} }
} }
@ -330,6 +325,8 @@ class serendipity_event_spamblock_bayes extends serendipity_event {
function initB8() { function initB8() {
global $serendipity; global $serendipity;
if ($this->$b8 === null) { if ($this->$b8 === null) {
$this->setupDB();
require_once(dirname(__FILE__) . '/b8/b8.php'); require_once(dirname(__FILE__) . '/b8/b8.php');
switch ($serendipity['dbType']) { switch ($serendipity['dbType']) {
case 'mysql': case 'mysql':