From 469d643530b61f2ec5059c06cba0bf5513d9c8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Wed, 22 May 2024 09:08:49 +0200 Subject: [PATCH] Drop af_user(_text) and afh_user(_text) fields They have been migrated to their respective _actor counterparts. Bug: T188180 Change-Id: I76ab3a4eeaf93bf009ba3a5d4a0315443b6839ef --- .../patch-drop-af_user.json | 194 ++++++++++++++++++ .../patch-drop-afh_user.json | 189 +++++++++++++++++ db_patches/mysql/patch-drop-af_user.sql | 9 + db_patches/mysql/patch-drop-afh_user.sql | 10 + db_patches/mysql/tables-generated.sql | 11 +- db_patches/postgres/patch-drop-af_user.sql | 11 + db_patches/postgres/patch-drop-afh_user.sql | 12 ++ db_patches/postgres/tables-generated.sql | 14 +- db_patches/sqlite/patch-drop-af_user.sql | 15 ++ db_patches/sqlite/patch-drop-afh_user.sql | 16 ++ db_patches/sqlite/tables-generated.sql | 14 +- db_patches/tables.json | 39 +--- .../Hooks/Handlers/SchemaChangesHandler.php | 12 ++ tests/phpunit/AbuseFilterConsequencesTest.php | 2 - .../Maintenance/SearchFiltersTest.php | 2 - 15 files changed, 476 insertions(+), 74 deletions(-) create mode 100644 db_patches/abstractSchemaChanges/patch-drop-af_user.json create mode 100644 db_patches/abstractSchemaChanges/patch-drop-afh_user.json create mode 100644 db_patches/mysql/patch-drop-af_user.sql create mode 100644 db_patches/mysql/patch-drop-afh_user.sql create mode 100644 db_patches/postgres/patch-drop-af_user.sql create mode 100644 db_patches/postgres/patch-drop-afh_user.sql create mode 100644 db_patches/sqlite/patch-drop-af_user.sql create mode 100644 db_patches/sqlite/patch-drop-afh_user.sql diff --git a/db_patches/abstractSchemaChanges/patch-drop-af_user.json b/db_patches/abstractSchemaChanges/patch-drop-af_user.json new file mode 100644 index 000000000..cb94f4ed4 --- /dev/null +++ b/db_patches/abstractSchemaChanges/patch-drop-af_user.json @@ -0,0 +1,194 @@ +{ + "comment": "Drop af_user and af_user_text fields from abuse_filter", + "before": { + "name": "abuse_filter", + "columns": [ + { + "name": "af_id", + "type": "bigint", + "options": { "notnull": true, "autoincrement": true, "unsigned": true } + }, + { + "name": "af_pattern", + "type": "blob", + "options": { "notnull": true, "length": 65530 } + }, + { + "name": "af_user", + "type": "bigint", + "options": { "notnull": true, "unsigned": true, "default": 0 } + }, + { + "name": "af_user_text", + "type": "binary", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "af_actor", + "type": "bigint", + "options": { "notnull": true, "unsigned": true, "default": 0 } + }, + { + "name": "af_timestamp", + "type": "mwtimestamp", + "options": { "notnull": true } + }, + { + "name": "af_enabled", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 1 } + }, + { + "name": "af_comments", + "type": "blob", + "options": { "notnull": false, "length": 65530 } + }, + { + "name": "af_public_comments", + "type": "blob", + "options": { "notnull": false, "length": 255 } + }, + { + "name": "af_hidden", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_hit_count", + "type": "bigint", + "options": { "notnull": true, "default": 0 } + }, + { + "name": "af_throttled", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_deleted", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_actions", + "type": "string", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "af_global", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_group", + "type": "binary", + "options": { "notnull": true, "length": 64, "default": "default" } + } + ], + "indexes": [ + { + "name": "af_user", + "columns": [ "af_user" ], + "unique": false + }, + { + "name": "af_actor", + "columns": [ "af_actor" ], + "unique": false + }, + { + "name": "af_group_enabled", + "columns": [ "af_group", "af_enabled", "af_id" ], + "unique": false + } + ], + "pk": [ "af_id" ] + }, + "after": { + "name": "abuse_filter", + "columns": [ + { + "name": "af_id", + "type": "bigint", + "options": { "notnull": true, "autoincrement": true, "unsigned": true } + }, + { + "name": "af_pattern", + "type": "blob", + "options": { "notnull": true, "length": 65530 } + }, + { + "name": "af_actor", + "type": "bigint", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "af_timestamp", + "type": "mwtimestamp", + "options": { "notnull": true } + }, + { + "name": "af_enabled", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 1 } + }, + { + "name": "af_comments", + "type": "blob", + "options": { "notnull": false, "length": 65530 } + }, + { + "name": "af_public_comments", + "type": "blob", + "options": { "notnull": false, "length": 255 } + }, + { + "name": "af_hidden", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_hit_count", + "type": "bigint", + "options": { "notnull": true, "default": 0 } + }, + { + "name": "af_throttled", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_deleted", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_actions", + "type": "string", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "af_global", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "af_group", + "type": "binary", + "options": { "notnull": true, "length": 64, "default": "default" } + } + ], + "indexes": [ + { + "name": "af_actor", + "columns": [ "af_actor" ], + "unique": false + }, + { + "name": "af_group_enabled", + "columns": [ "af_group", "af_enabled", "af_id" ], + "unique": false + } + ], + "pk": [ "af_id" ] + } +} diff --git a/db_patches/abstractSchemaChanges/patch-drop-afh_user.json b/db_patches/abstractSchemaChanges/patch-drop-afh_user.json new file mode 100644 index 000000000..da77e99f7 --- /dev/null +++ b/db_patches/abstractSchemaChanges/patch-drop-afh_user.json @@ -0,0 +1,189 @@ +{ + "comment": "Drop afh_user and afh_user_text fields from abuse_filter_history", + "before": { + "name": "abuse_filter_history", + "columns": [ + { + "name": "afh_id", + "type": "bigint", + "options": { "notnull": true, "autoincrement": true, "unsigned": true } + }, + { + "name": "afh_filter", + "type": "bigint", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "afh_user", + "type": "bigint", + "options": { "notnull": true, "unsigned": true, "default": 0 } + }, + { + "name": "afh_user_text", + "type": "binary", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "afh_actor", + "type": "bigint", + "options": { "notnull": true, "unsigned": true, "default": 0 } + }, + { + "name": "afh_timestamp", + "type": "mwtimestamp", + "options": { "notnull": true } + }, + { + "name": "afh_pattern", + "type": "blob", + "options": { "notnull": true, "length": 65530 } + }, + { + "name": "afh_comments", + "type": "blob", + "options": { "notnull": true, "length": 65530 } + }, + { + "name": "afh_flags", + "type": "blob", + "options": { "notnull": true, "length": 255 } + }, + { + "name": "afh_public_comments", + "type": "blob", + "options": { "notnull": false, "length": 255 } + }, + { + "name": "afh_actions", + "type": "blob", + "options": { "notnull": false, "length": 65530 } + }, + { + "name": "afh_deleted", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "afh_changed_fields", + "type": "string", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "afh_group", + "type": "binary", + "options": { "notnull": false, "length": 64 } + } + ], + "indexes": [ + { + "name": "afh_filter", + "columns": [ "afh_filter" ], + "unique": false + }, + { + "name": "afh_user", + "columns": [ "afh_user" ], + "unique": false + }, + { + "name": "afh_user_text", + "columns": [ "afh_user_text" ], + "unique": false + }, + { + "name": "afh_actor", + "columns": [ "afh_actor" ], + "unique": false + }, + { + "name": "afh_timestamp", + "columns": [ "afh_timestamp" ], + "unique": false + } + ], + "pk": [ "afh_id" ] + }, + "after": { + "name": "abuse_filter_history", + "columns": [ + { + "name": "afh_id", + "type": "bigint", + "options": { "notnull": true, "autoincrement": true, "unsigned": true } + }, + { + "name": "afh_filter", + "type": "bigint", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "afh_actor", + "type": "bigint", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "afh_timestamp", + "type": "mwtimestamp", + "options": { "notnull": true } + }, + { + "name": "afh_pattern", + "type": "blob", + "options": { "notnull": true, "length": 65530 } + }, + { + "name": "afh_comments", + "type": "blob", + "options": { "notnull": true, "length": 65530 } + }, + { + "name": "afh_flags", + "type": "blob", + "options": { "notnull": true, "length": 255 } + }, + { + "name": "afh_public_comments", + "type": "blob", + "options": { "notnull": false, "length": 255 } + }, + { + "name": "afh_actions", + "type": "blob", + "options": { "notnull": false, "length": 65530 } + }, + { + "name": "afh_deleted", + "type": "mwtinyint", + "options": { "notnull": true, "length": 1, "default": 0 } + }, + { + "name": "afh_changed_fields", + "type": "string", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "afh_group", + "type": "binary", + "options": { "notnull": false, "length": 64 } + } + ], + "indexes": [ + { + "name": "afh_filter", + "columns": [ "afh_filter" ], + "unique": false + }, + { + "name": "afh_actor", + "columns": [ "afh_actor" ], + "unique": false + }, + { + "name": "afh_timestamp", + "columns": [ "afh_timestamp" ], + "unique": false + } + ], + "pk": [ "afh_id" ] + } +} diff --git a/db_patches/mysql/patch-drop-af_user.sql b/db_patches/mysql/patch-drop-af_user.sql new file mode 100644 index 000000000..4f68a442f --- /dev/null +++ b/db_patches/mysql/patch-drop-af_user.sql @@ -0,0 +1,9 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: db_patches/abstractSchemaChanges/patch-drop-af_user.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +DROP INDEX af_user ON /*_*/abuse_filter; +ALTER TABLE /*_*/abuse_filter +DROP af_user, +DROP af_user_text, +CHANGE af_actor af_actor BIGINT UNSIGNED NOT NULL; \ No newline at end of file diff --git a/db_patches/mysql/patch-drop-afh_user.sql b/db_patches/mysql/patch-drop-afh_user.sql new file mode 100644 index 000000000..6c101f3fe --- /dev/null +++ b/db_patches/mysql/patch-drop-afh_user.sql @@ -0,0 +1,10 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: db_patches/abstractSchemaChanges/patch-drop-afh_user.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +DROP INDEX afh_user ON /*_*/abuse_filter_history; +DROP INDEX afh_user_text ON /*_*/abuse_filter_history; +ALTER TABLE /*_*/abuse_filter_history +DROP afh_user, +DROP afh_user_text, +CHANGE afh_actor afh_actor BIGINT UNSIGNED NOT NULL; \ No newline at end of file diff --git a/db_patches/mysql/tables-generated.sql b/db_patches/mysql/tables-generated.sql index 7bafbb9ab..14e79ec15 100644 --- a/db_patches/mysql/tables-generated.sql +++ b/db_patches/mysql/tables-generated.sql @@ -5,9 +5,7 @@ CREATE TABLE /*_*/abuse_filter ( af_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, af_pattern BLOB NOT NULL, - af_user BIGINT UNSIGNED DEFAULT 0 NOT NULL, - af_user_text VARBINARY(255) DEFAULT '' NOT NULL, - af_actor BIGINT UNSIGNED DEFAULT 0 NOT NULL, + af_actor BIGINT UNSIGNED NOT NULL, af_timestamp BINARY(14) NOT NULL, af_enabled TINYINT(1) DEFAULT 1 NOT NULL, af_comments BLOB DEFAULT NULL, @@ -19,7 +17,6 @@ CREATE TABLE /*_*/abuse_filter ( af_actions VARCHAR(255) DEFAULT '' NOT NULL, af_global TINYINT(1) DEFAULT 0 NOT NULL, af_group VARBINARY(64) DEFAULT 'default' NOT NULL, - INDEX af_user (af_user), INDEX af_actor (af_actor), INDEX af_group_enabled (af_group, af_enabled, af_id), PRIMARY KEY(af_id) @@ -72,9 +69,7 @@ CREATE TABLE /*_*/abuse_filter_log ( CREATE TABLE /*_*/abuse_filter_history ( afh_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, afh_filter BIGINT UNSIGNED NOT NULL, - afh_user BIGINT UNSIGNED DEFAULT 0 NOT NULL, - afh_user_text VARBINARY(255) DEFAULT '' NOT NULL, - afh_actor BIGINT UNSIGNED DEFAULT 0 NOT NULL, + afh_actor BIGINT UNSIGNED NOT NULL, afh_timestamp BINARY(14) NOT NULL, afh_pattern BLOB NOT NULL, afh_comments BLOB NOT NULL, @@ -85,8 +80,6 @@ CREATE TABLE /*_*/abuse_filter_history ( afh_changed_fields VARCHAR(255) DEFAULT '' NOT NULL, afh_group VARBINARY(64) DEFAULT NULL, INDEX afh_filter (afh_filter), - INDEX afh_user (afh_user), - INDEX afh_user_text (afh_user_text), INDEX afh_actor (afh_actor), INDEX afh_timestamp (afh_timestamp), PRIMARY KEY(afh_id) diff --git a/db_patches/postgres/patch-drop-af_user.sql b/db_patches/postgres/patch-drop-af_user.sql new file mode 100644 index 000000000..bd3f079ba --- /dev/null +++ b/db_patches/postgres/patch-drop-af_user.sql @@ -0,0 +1,11 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: db_patches/abstractSchemaChanges/patch-drop-af_user.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +DROP INDEX af_user; +ALTER TABLE abuse_filter +DROP af_user; +ALTER TABLE abuse_filter +DROP af_user_text; +ALTER TABLE abuse_filter ALTER af_actor +DROP DEFAULT; \ No newline at end of file diff --git a/db_patches/postgres/patch-drop-afh_user.sql b/db_patches/postgres/patch-drop-afh_user.sql new file mode 100644 index 000000000..10dece2ae --- /dev/null +++ b/db_patches/postgres/patch-drop-afh_user.sql @@ -0,0 +1,12 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: db_patches/abstractSchemaChanges/patch-drop-afh_user.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +DROP INDEX afh_user; +DROP INDEX afh_user_text; +ALTER TABLE abuse_filter_history +DROP afh_user; +ALTER TABLE abuse_filter_history +DROP afh_user_text; +ALTER TABLE abuse_filter_history ALTER afh_actor +DROP DEFAULT; \ No newline at end of file diff --git a/db_patches/postgres/tables-generated.sql b/db_patches/postgres/tables-generated.sql index 56dcea115..4e9c3c3d1 100644 --- a/db_patches/postgres/tables-generated.sql +++ b/db_patches/postgres/tables-generated.sql @@ -5,9 +5,7 @@ CREATE TABLE abuse_filter ( af_id BIGSERIAL NOT NULL, af_pattern TEXT NOT NULL, - af_user BIGINT DEFAULT 0 NOT NULL, - af_user_text TEXT DEFAULT '' NOT NULL, - af_actor BIGINT DEFAULT 0 NOT NULL, + af_actor BIGINT NOT NULL, af_timestamp TIMESTAMPTZ NOT NULL, af_enabled SMALLINT DEFAULT 1 NOT NULL, af_comments TEXT DEFAULT NULL, @@ -22,8 +20,6 @@ CREATE TABLE abuse_filter ( PRIMARY KEY(af_id) ); -CREATE INDEX af_user ON abuse_filter (af_user); - CREATE INDEX af_actor ON abuse_filter (af_actor); CREATE INDEX af_group_enabled ON abuse_filter (af_group, af_enabled, af_id); @@ -83,9 +79,7 @@ CREATE INDEX afl_wiki_timestamp ON abuse_filter_log (afl_wiki, afl_timestamp); CREATE TABLE abuse_filter_history ( afh_id BIGSERIAL NOT NULL, afh_filter BIGINT NOT NULL, - afh_user BIGINT DEFAULT 0 NOT NULL, - afh_user_text TEXT DEFAULT '' NOT NULL, - afh_actor BIGINT DEFAULT 0 NOT NULL, + afh_actor BIGINT NOT NULL, afh_timestamp TIMESTAMPTZ NOT NULL, afh_pattern TEXT NOT NULL, afh_comments TEXT NOT NULL, @@ -100,10 +94,6 @@ CREATE TABLE abuse_filter_history ( CREATE INDEX afh_filter ON abuse_filter_history (afh_filter); -CREATE INDEX afh_user ON abuse_filter_history (afh_user); - -CREATE INDEX afh_user_text ON abuse_filter_history (afh_user_text); - CREATE INDEX afh_actor ON abuse_filter_history (afh_actor); CREATE INDEX afh_timestamp ON abuse_filter_history (afh_timestamp); diff --git a/db_patches/sqlite/patch-drop-af_user.sql b/db_patches/sqlite/patch-drop-af_user.sql new file mode 100644 index 000000000..6c8d9e46b --- /dev/null +++ b/db_patches/sqlite/patch-drop-af_user.sql @@ -0,0 +1,15 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: db_patches/abstractSchemaChanges/patch-drop-af_user.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +CREATE TEMPORARY TABLE /*_*/__temp__abuse_filter AS +SELECT af_id, af_pattern, af_actor, af_timestamp, af_enabled, af_comments, af_public_comments, af_hidden, af_hit_count, af_throttled, af_deleted, af_actions, af_global, af_group +FROM /*_*/abuse_filter; +DROP TABLE /*_*/abuse_filter; +CREATE TABLE /*_*/abuse_filter ( af_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, af_pattern BLOB NOT NULL, af_actor BIGINT UNSIGNED NOT NULL, af_timestamp BLOB NOT NULL, af_enabled SMALLINT DEFAULT 1 NOT NULL, af_comments BLOB DEFAULT NULL, af_public_comments BLOB DEFAULT NULL, af_hidden SMALLINT DEFAULT 0 NOT NULL, af_hit_count BIGINT DEFAULT 0 NOT NULL, af_throttled SMALLINT DEFAULT 0 NOT NULL, af_deleted SMALLINT DEFAULT 0 NOT NULL, af_actions VARCHAR(255) DEFAULT '' NOT NULL, af_global SMALLINT DEFAULT 0 NOT NULL, af_group BLOB DEFAULT 'default' NOT NULL ); +INSERT INTO /*_*/abuse_filter ( af_id, af_pattern, af_actor, af_timestamp, af_enabled, af_comments, af_public_comments, af_hidden, af_hit_count, af_throttled, af_deleted, af_actions, af_global, af_group ) +SELECT af_id, af_pattern, af_actor, af_timestamp, af_enabled, af_comments, af_public_comments, af_hidden, af_hit_count, af_throttled, af_deleted, af_actions, af_global, af_group +FROM /*_*/__temp__abuse_filter; +DROP TABLE /*_*/__temp__abuse_filter; +CREATE INDEX af_actor ON /*_*/abuse_filter (af_actor); +CREATE INDEX af_group_enabled ON /*_*/abuse_filter (af_group, af_enabled, af_id); \ No newline at end of file diff --git a/db_patches/sqlite/patch-drop-afh_user.sql b/db_patches/sqlite/patch-drop-afh_user.sql new file mode 100644 index 000000000..1421ff917 --- /dev/null +++ b/db_patches/sqlite/patch-drop-afh_user.sql @@ -0,0 +1,16 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: db_patches/abstractSchemaChanges/patch-drop-afh_user.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +CREATE TEMPORARY TABLE /*_*/__temp__abuse_filter_history AS +SELECT afh_id, afh_filter, afh_actor, afh_timestamp, afh_pattern, afh_comments, afh_flags, afh_public_comments, afh_actions, afh_deleted, afh_changed_fields, afh_group +FROM /*_*/abuse_filter_history; +DROP TABLE /*_*/abuse_filter_history; +CREATE TABLE /*_*/abuse_filter_history ( afh_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, afh_filter BIGINT UNSIGNED NOT NULL, afh_actor BIGINT UNSIGNED NOT NULL, afh_timestamp BLOB NOT NULL, afh_pattern BLOB NOT NULL, afh_comments BLOB NOT NULL, afh_flags BLOB NOT NULL, afh_public_comments BLOB DEFAULT NULL, afh_actions BLOB DEFAULT NULL, afh_deleted SMALLINT DEFAULT 0 NOT NULL, afh_changed_fields VARCHAR(255) DEFAULT '' NOT NULL, afh_group BLOB DEFAULT NULL ); +INSERT INTO /*_*/abuse_filter_history ( afh_id, afh_filter, afh_actor, afh_timestamp, afh_pattern, afh_comments, afh_flags, afh_public_comments, afh_actions, afh_deleted, afh_changed_fields, afh_group ) +SELECT afh_id, afh_filter, afh_actor, afh_timestamp, afh_pattern, afh_comments, afh_flags, afh_public_comments, afh_actions, afh_deleted, afh_changed_fields, afh_group +FROM /*_*/__temp__abuse_filter_history; +DROP TABLE /*_*/__temp__abuse_filter_history; +CREATE INDEX afh_filter ON /*_*/abuse_filter_history (afh_filter); +CREATE INDEX afh_actor ON /*_*/abuse_filter_history (afh_actor); +CREATE INDEX afh_timestamp ON /*_*/abuse_filter_history (afh_timestamp); \ No newline at end of file diff --git a/db_patches/sqlite/tables-generated.sql b/db_patches/sqlite/tables-generated.sql index 020f44414..222136897 100644 --- a/db_patches/sqlite/tables-generated.sql +++ b/db_patches/sqlite/tables-generated.sql @@ -5,9 +5,7 @@ CREATE TABLE /*_*/abuse_filter ( af_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, af_pattern BLOB NOT NULL, - af_user BIGINT UNSIGNED DEFAULT 0 NOT NULL, - af_user_text BLOB DEFAULT '' NOT NULL, - af_actor BIGINT UNSIGNED DEFAULT 0 NOT NULL, + af_actor BIGINT UNSIGNED NOT NULL, af_timestamp BLOB NOT NULL, af_enabled SMALLINT DEFAULT 1 NOT NULL, af_comments BLOB DEFAULT NULL, @@ -21,8 +19,6 @@ CREATE TABLE /*_*/abuse_filter ( af_group BLOB DEFAULT 'default' NOT NULL ); -CREATE INDEX af_user ON /*_*/abuse_filter (af_user); - CREATE INDEX af_actor ON /*_*/abuse_filter (af_actor); CREATE INDEX af_group_enabled ON /*_*/abuse_filter (af_group, af_enabled, af_id); @@ -81,9 +77,7 @@ CREATE INDEX afl_wiki_timestamp ON /*_*/abuse_filter_log (afl_wiki, afl_timestam CREATE TABLE /*_*/abuse_filter_history ( afh_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, afh_filter BIGINT UNSIGNED NOT NULL, - afh_user BIGINT UNSIGNED DEFAULT 0 NOT NULL, - afh_user_text BLOB DEFAULT '' NOT NULL, - afh_actor BIGINT UNSIGNED DEFAULT 0 NOT NULL, + afh_actor BIGINT UNSIGNED NOT NULL, afh_timestamp BLOB NOT NULL, afh_pattern BLOB NOT NULL, afh_comments BLOB NOT NULL, @@ -97,10 +91,6 @@ CREATE TABLE /*_*/abuse_filter_history ( CREATE INDEX afh_filter ON /*_*/abuse_filter_history (afh_filter); -CREATE INDEX afh_user ON /*_*/abuse_filter_history (afh_user); - -CREATE INDEX afh_user_text ON /*_*/abuse_filter_history (afh_user_text); - CREATE INDEX afh_actor ON /*_*/abuse_filter_history (afh_actor); CREATE INDEX afh_timestamp ON /*_*/abuse_filter_history (afh_timestamp); diff --git a/db_patches/tables.json b/db_patches/tables.json index 4f6f14e88..4759f3764 100644 --- a/db_patches/tables.json +++ b/db_patches/tables.json @@ -12,20 +12,10 @@ "type": "blob", "options": { "notnull": true, "length": 65530 } }, - { - "name": "af_user", - "type": "bigint", - "options": { "notnull": true, "unsigned": true, "default": 0 } - }, - { - "name": "af_user_text", - "type": "binary", - "options": { "notnull": true, "length": 255, "default": "" } - }, { "name": "af_actor", "type": "bigint", - "options": { "notnull": true, "unsigned": true, "default": 0 } + "options": { "notnull": true, "unsigned": true } }, { "name": "af_timestamp", @@ -84,11 +74,6 @@ } ], "indexes": [ - { - "name": "af_user", - "columns": [ "af_user" ], - "unique": false - }, { "name": "af_actor", "columns": [ "af_actor" ], @@ -266,20 +251,10 @@ "type": "bigint", "options": { "notnull": true, "unsigned": true } }, - { - "name": "afh_user", - "type": "bigint", - "options": { "notnull": true, "unsigned": true, "default": 0 } - }, - { - "name": "afh_user_text", - "type": "binary", - "options": { "notnull": true, "length": 255, "default": "" } - }, { "name": "afh_actor", "type": "bigint", - "options": { "notnull": true, "unsigned": true, "default": 0 } + "options": { "notnull": true, "unsigned": true } }, { "name": "afh_timestamp", @@ -333,16 +308,6 @@ "columns": [ "afh_filter" ], "unique": false }, - { - "name": "afh_user", - "columns": [ "afh_user" ], - "unique": false - }, - { - "name": "afh_user_text", - "columns": [ "afh_user_text" ], - "unique": false - }, { "name": "afh_actor", "columns": [ "afh_actor" ], diff --git a/includes/Hooks/Handlers/SchemaChangesHandler.php b/includes/Hooks/Handlers/SchemaChangesHandler.php index e528fdf61..18c958548 100644 --- a/includes/Hooks/Handlers/SchemaChangesHandler.php +++ b/includes/Hooks/Handlers/SchemaChangesHandler.php @@ -183,6 +183,18 @@ class SchemaChangesHandler implements LoadExtensionSchemaUpdatesHook { __DIR__ . '/../../../maintenance/MigrateActorsAF.php', ] ); + // 1.43 + $updater->addExtensionUpdate( [ + 'dropField', 'abuse_filter', 'af_user', + "$dir/$dbType/patch-drop-af_user.sql", true + ] ); + + // 1.43 + $updater->addExtensionUpdate( [ + 'dropField', 'abuse_filter_history', 'afh_user', + "$dir/$dbType/patch-drop-afh_user.sql", true + ] ); + $updater->addExtensionUpdate( [ [ $this, 'createAbuseFilterUser' ] ] ); // 1.35 $updater->addPostDatabaseUpdateMaintenance( UpdateVarDumps::class ); diff --git a/tests/phpunit/AbuseFilterConsequencesTest.php b/tests/phpunit/AbuseFilterConsequencesTest.php index 6aabeda95..fdc3b55af 100644 --- a/tests/phpunit/AbuseFilterConsequencesTest.php +++ b/tests/phpunit/AbuseFilterConsequencesTest.php @@ -349,8 +349,6 @@ class AbuseFilterConsequencesTest extends MediaWikiIntegrationTestCase { $dbw = $this->getDb(); $defaultRowSection = [ - 'af_user' => 0, - 'af_user_text' => 'FilterTester', 'af_actor' => 1, 'af_timestamp' => $dbw->timestamp(), 'af_group' => 'default', diff --git a/tests/phpunit/integration/Maintenance/SearchFiltersTest.php b/tests/phpunit/integration/Maintenance/SearchFiltersTest.php index 6db198cc0..5b8bdb227 100644 --- a/tests/phpunit/integration/Maintenance/SearchFiltersTest.php +++ b/tests/phpunit/integration/Maintenance/SearchFiltersTest.php @@ -37,8 +37,6 @@ class SearchFiltersTest extends MaintenanceBaseTestCase { */ public function addDBData() { $defaultRow = [ - 'af_user' => 0, - 'af_user_text' => 'FilterTester', 'af_actor' => 1, 'af_timestamp' => $this->db->timestamp( '20190826000000' ), 'af_enabled' => 1,