diff --git a/db_patches/patch-afl-namespace_int.sqlite.sql b/db_patches/patch-afl-namespace_int.sqlite.sql new file mode 100644 index 000000000..d48f18108 --- /dev/null +++ b/db_patches/patch-afl-namespace_int.sqlite.sql @@ -0,0 +1,45 @@ +-- (Just) change afl_namespace field to int NOT NULL. +BEGIN; + +DROP TABLE IF EXISTS /*_*/abuse_filter_log_tmp; + +CREATE TABLE /*_*/abuse_filter_log_tmp ( + afl_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + afl_filter varbinary(64) NOT NULL, + afl_user BIGINT unsigned NOT NULL, + afl_user_text varbinary(255) NOT NULL, + afl_ip varbinary(255) not null, + afl_action varbinary(255) not null, + afl_actions varbinary(255) not null, + afl_var_dump BLOB NOT NULL, + afl_timestamp varbinary(14) NOT NULL, + afl_namespace int NOT NULL, + afl_title varbinary(255) NOT NULL, + afl_wiki varbinary(64) NULL, + afl_deleted tinyint(1) NOT NULL DEFAULT 0, + afl_patrolled_by int unsigned NULL, + afl_rev_id int unsigned, + afl_log_id int unsigned +) /*$wgDBTableOptions*/; + +INSERT OR IGNORE INTO /*_*/abuse_filter_log_tmp ( + afl_id, afl_filter, afl_user, afl_user_text, afl_ip, afl_action, afl_actions, + afl_var_dump, afl_timestamp, afl_namespace, afl_title, afl_wiki, afl_deleted, + afl_patrolled_by, afl_rev_id, afl_log_id) + SELECT afl_id, afl_filter, afl_user, afl_user_text, afl_ip, afl_action, afl_actions, + afl_var_dump, afl_timestamp, afl_namespace, afl_title, afl_wiki, afl_deleted, + afl_patrolled_by, afl_rev_id, afl_log_id + FROM /*_*/abuse_filter_log; + +DROP TABLE /*_*/abuse_filter_log; +ALTER TABLE /*_*/abuse_filter_log_tmp RENAME TO /*_*/abuse_filter_log; +CREATE INDEX /*i*/afl_filter_timestamp ON /*_*/abuse_filter_log (afl_filter,afl_timestamp); +CREATE INDEX /*i*/afl_user_timestamp ON /*_*/abuse_filter_log (afl_user,afl_user_text,afl_timestamp); +CREATE INDEX /*i*/afl_timestamp ON /*_*/abuse_filter_log (afl_timestamp); +CREATE INDEX /*i*/afl_page_timestamp ON /*_*/abuse_filter_log (afl_namespace, afl_title, afl_timestamp); +CREATE INDEX /*i*/afl_ip_timestamp ON /*_*/abuse_filter_log (afl_ip, afl_timestamp); +CREATE INDEX /*i*/afl_wiki_timestamp ON /*_*/abuse_filter_log (afl_wiki, afl_timestamp); +CREATE INDEX /*i*/afl_rev_id ON /*_*/abuse_filter_log (afl_rev_id); +CREATE INDEX /*i*/afl_log_id ON /*_*/abuse_filter_log (afl_log_id); + +COMMIT; \ No newline at end of file diff --git a/db_patches/patch-global_logging_wiki-index.sqlite.sql b/db_patches/patch-global_logging_wiki-index.sqlite.sql index 45c619c6b..694b6e3d4 100644 --- a/db_patches/patch-global_logging_wiki-index.sqlite.sql +++ b/db_patches/patch-global_logging_wiki-index.sqlite.sql @@ -1,3 +1,3 @@ --- Add abuse_filter_log idex for afl_wiki. +-- Add abuse_filter_log index for afl_wiki. CREATE INDEX afl_wiki_timestamp ON /*$wgDBprefix*/abuse_filter_log (afl_wiki, afl_timestamp); diff --git a/includes/AbuseFilterHooks.php b/includes/AbuseFilterHooks.php index 3d64f37d3..aa9bad55f 100644 --- a/includes/AbuseFilterHooks.php +++ b/includes/AbuseFilterHooks.php @@ -563,35 +563,19 @@ class AbuseFilterHooks { 'addIndex', 'abuse_filter_log', 'wiki_timestamp', "$dir/db_patches/patch-global_logging_wiki-index.sql", true ] ); - } else { - $updater->addExtensionUpdate( [ - 'addIndex', 'abuse_filter_log', 'afl_wiki_timestamp', - "$dir/db_patches/patch-global_logging_wiki-index.sqlite.sql", true - ] ); - } - - if ( $updater->getDB()->getType() == 'mysql' ) { $updater->addExtensionUpdate( [ 'modifyField', 'abuse_filter_log', 'afl_namespace', "$dir/db_patches/patch-afl-namespace_int.sql", true ] ); } else { - /* - $updater->addExtensionUpdate( array( - 'modifyField', - 'abuse_filter_log', - 'afl_namespace', - "$dir/db_patches/patch-afl-namespace_int.sqlite.sql", - true - ) ); - */ - /* @todo Modify a column in sqlite, which do not support such - * things create backup, drop, create with new schema, copy, - * drop backup or simply see - * https://www.mediawiki.org/wiki/Manual:SQLite#About_SQLite : - * Several extensions are known to have database update or - * installation issues with SQLite: AbuseFilter, ... - */ + $updater->addExtensionUpdate( [ + 'addIndex', 'abuse_filter_log', 'afl_wiki_timestamp', + "$dir/db_patches/patch-global_logging_wiki-index.sqlite.sql", true + ] ); + $updater->addExtensionUpdate( [ + 'modifyField', 'abuse_filter_log', 'afl_namespace', + "$dir/db_patches/patch-afl-namespace_int.sqlite.sql", true + ] ); } } elseif ( $updater->getDB()->getType() == 'postgres' ) { $updater->addExtensionUpdate( [