diff --git a/includes/Hooks.php b/includes/Hooks.php index 991fd65c..b4b33274 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -65,6 +65,9 @@ class Hooks implements $updater->addExtensionField( 'linter', 'linter_template', dirname( __DIR__ ) . '/sql/patch-linter-template-tag-fields.sql' ); + $updater->modifyExtensionField( 'linter', 'linter_params', + dirname( __DIR__ ) . '/sql/patch-linter-fix-params-null-definition.sql' + ); } elseif ( $dbType === 'sqlite' ) { $updater->addExtensionTable( 'linter', dirname( __DIR__ ) . '/sql/sqlite/tables-generated.sql' @@ -75,6 +78,9 @@ class Hooks implements $updater->addExtensionField( 'linter', 'linter_template', dirname( __DIR__ ) . '/sql/sqlite/patch-linter-template-tag-fields.sql' ); + $updater->modifyExtensionField( 'linter', 'linter_params', + dirname( __DIR__ ) . '/sql/sqlite/patch-linter-fix-params-null-definition.sql' + ); } elseif ( $dbType === 'postgres' ) { $updater->addExtensionTable( 'linter', dirname( __DIR__ ) . '/sql/postgres/tables-generated.sql' @@ -85,6 +91,9 @@ class Hooks implements $updater->addExtensionField( 'linter', 'linter_template', dirname( __DIR__ ) . '/sql/postgres/patch-linter-template-tag-fields.sql' ); + $updater->modifyExtensionField( 'linter', 'linter_params', + dirname( __DIR__ ) . '/sql/postgres/patch-linter-fix-params-null-definition.sql' + ); } } diff --git a/sql/abstractSchemaChanges/patch-linter-fix-params-null-definition.json b/sql/abstractSchemaChanges/patch-linter-fix-params-null-definition.json new file mode 100644 index 00000000..2ef21346 --- /dev/null +++ b/sql/abstractSchemaChanges/patch-linter-fix-params-null-definition.json @@ -0,0 +1,185 @@ +{ + "comment": "Fix linter table linter_params definition to not be nullable (T327806)", + "before": { + "name": "linter", + "columns": [ + { + "name": "linter_id", + "type": "integer", + "options": { "notnull": true, "unsigned": true, "autoincrement": true } + }, + { + "name": "linter_page", + "comment": "page id", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_namespace", + "comment": "page namespace", + "type": "integer", + "options": { "notnull": false, "unsigned": false } + }, + { + "name": "linter_cat", + "comment": "error category (see CategoryManager::$categoryIds)", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_start", + "comment": "end positions of where the error is located", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_end", + "comment": "end positions of where the error is located", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_params", + "comment": "extra parameters about the error, JSON encoded", + "type": "blob", + "options": { "length": 65530, "notnull": false } + }, + { + "name": "linter_template", + "comment": "name of a template if used or empty", + "type": "binary", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "linter_tag", + "comment": "name of tag if used or empty", + "type": "binary", + "options": { "notnull": true, "length": 32, "default": "" } + } + ], + "indexes": [ + { + "name": "linter_page", + "comment": "Query by page", + "columns": [ "linter_page" ], + "unique": false + }, + { + "name": "linter_cat_namespace", + "comment": "Query by category and namespace", + "columns": [ "linter_cat", "linter_namespace" ], + "unique": false + }, + { + "name": "linter_cat_page_position", + "comment": "Unique index for lint errors, also covers linter_cat for query by category", + "columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ], + "unique": true + }, + { + "name": "linter_cat_template", + "comment": "Query by template", + "columns": [ "linter_cat", "linter_template" ], + "unique": false + }, + { + "name": "linter_cat_tag", + "comment": "Query by tag", + "columns": [ "linter_cat", "linter_tag" ], + "unique": false + } + ], + "pk": [ "linter_id" ] + }, + "after": { + "name": "linter", + "columns": [ + { + "name": "linter_id", + "type": "integer", + "options": { "notnull": true, "unsigned": true, "autoincrement": true } + }, + { + "name": "linter_page", + "comment": "page id", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_namespace", + "comment": "page namespace", + "type": "integer", + "options": { "notnull": false, "unsigned": false } + }, + { + "name": "linter_cat", + "comment": "error category (see CategoryManager::$categoryIds)", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_start", + "comment": "end positions of where the error is located", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_end", + "comment": "end positions of where the error is located", + "type": "integer", + "options": { "notnull": true, "unsigned": true } + }, + { + "name": "linter_params", + "comment": "extra parameters about the error, JSON encoded", + "type": "blob", + "options": { "length": 65530, "notnull": true } + }, + { + "name": "linter_template", + "comment": "name of a template if used or empty", + "type": "binary", + "options": { "notnull": true, "length": 255, "default": "" } + }, + { + "name": "linter_tag", + "comment": "name of tag if used or empty", + "type": "binary", + "options": { "notnull": true, "length": 32, "default": "" } + } + ], + "indexes": [ + { + "name": "linter_page", + "comment": "Query by page", + "columns": [ "linter_page" ], + "unique": false + }, + { + "name": "linter_cat_namespace", + "comment": "Query by category and namespace", + "columns": [ "linter_cat", "linter_namespace" ], + "unique": false + }, + { + "name": "linter_cat_page_position", + "comment": "Unique index for lint errors, also covers linter_cat for query by category", + "columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ], + "unique": true + }, + { + "name": "linter_cat_template", + "comment": "Query by template", + "columns": [ "linter_cat", "linter_template" ], + "unique": false + }, + { + "name": "linter_cat_tag", + "comment": "Query by tag", + "columns": [ "linter_cat", "linter_tag" ], + "unique": false + } + ], + "pk": [ "linter_id" ] + } +} diff --git a/sql/patch-linter-fix-params-null-definition.sql b/sql/patch-linter-fix-params-null-definition.sql new file mode 100644 index 00000000..67f5d8ef --- /dev/null +++ b/sql/patch-linter-fix-params-null-definition.sql @@ -0,0 +1,6 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +ALTER TABLE /*_*/linter +CHANGE linter_params linter_params BLOB NOT NULL; \ No newline at end of file diff --git a/sql/postgres/patch-linter-fix-params-null-definition.sql b/sql/postgres/patch-linter-fix-params-null-definition.sql new file mode 100644 index 00000000..147eff25 --- /dev/null +++ b/sql/postgres/patch-linter-fix-params-null-definition.sql @@ -0,0 +1,6 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +ALTER TABLE linter ALTER linter_params +SET NOT NULL; \ No newline at end of file diff --git a/sql/postgres/tables-generated.sql b/sql/postgres/tables-generated.sql index 76d6e4ff..bd7b68fc 100644 --- a/sql/postgres/tables-generated.sql +++ b/sql/postgres/tables-generated.sql @@ -9,7 +9,7 @@ CREATE TABLE linter ( linter_cat INT NOT NULL, linter_start INT NOT NULL, linter_end INT NOT NULL, - linter_params TEXT DEFAULT NULL, + linter_params TEXT NOT NULL, linter_template TEXT DEFAULT '' NOT NULL, linter_tag TEXT DEFAULT '' NOT NULL, PRIMARY KEY(linter_id) diff --git a/sql/sqlite/patch-linter-fix-params-null-definition.sql b/sql/sqlite/patch-linter-fix-params-null-definition.sql new file mode 100644 index 00000000..0766b8f2 --- /dev/null +++ b/sql/sqlite/patch-linter-fix-params-null-definition.sql @@ -0,0 +1,18 @@ +-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. +-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json +-- Do not modify this file directly. +-- See https://www.mediawiki.org/wiki/Manual:Schema_changes +CREATE TEMPORARY TABLE /*_*/__temp__linter AS +SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag +FROM /*_*/linter; +DROP TABLE /*_*/linter; +CREATE TABLE /*_*/linter ( linter_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, linter_page INTEGER UNSIGNED NOT NULL, linter_namespace INTEGER DEFAULT NULL, linter_cat INTEGER UNSIGNED NOT NULL, linter_start INTEGER UNSIGNED NOT NULL, linter_end INTEGER UNSIGNED NOT NULL, linter_params BLOB NOT NULL, linter_template BLOB DEFAULT '' NOT NULL, linter_tag BLOB DEFAULT '' NOT NULL ); +INSERT INTO /*_*/linter ( linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag ) +SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag +FROM /*_*/__temp__linter; +DROP TABLE /*_*/__temp__linter; +CREATE INDEX linter_page ON /*_*/linter (linter_page); +CREATE INDEX linter_cat_namespace ON /*_*/linter (linter_cat, linter_namespace); +CREATE UNIQUE INDEX linter_cat_page_position ON /*_*/linter ( linter_cat, linter_page, linter_start, linter_end ); +CREATE INDEX linter_cat_template ON /*_*/linter (linter_cat, linter_template); +CREATE INDEX linter_cat_tag ON /*_*/linter (linter_cat, linter_tag); \ No newline at end of file diff --git a/sql/sqlite/tables-generated.sql b/sql/sqlite/tables-generated.sql index 5dbe9fb9..e07f965e 100644 --- a/sql/sqlite/tables-generated.sql +++ b/sql/sqlite/tables-generated.sql @@ -9,7 +9,7 @@ CREATE TABLE /*_*/linter ( linter_cat INTEGER UNSIGNED NOT NULL, linter_start INTEGER UNSIGNED NOT NULL, linter_end INTEGER UNSIGNED NOT NULL, - linter_params BLOB DEFAULT NULL, linter_template BLOB DEFAULT '' NOT NULL, + linter_params BLOB NOT NULL, linter_template BLOB DEFAULT '' NOT NULL, linter_tag BLOB DEFAULT '' NOT NULL ); diff --git a/sql/tables-generated.sql b/sql/tables-generated.sql index e8631aa3..455fe1e9 100644 --- a/sql/tables-generated.sql +++ b/sql/tables-generated.sql @@ -9,7 +9,7 @@ CREATE TABLE /*_*/linter ( linter_cat INT UNSIGNED NOT NULL, linter_start INT UNSIGNED NOT NULL, linter_end INT UNSIGNED NOT NULL, - linter_params BLOB DEFAULT NULL, + linter_params BLOB NOT NULL, linter_template VARBINARY(255) DEFAULT '' NOT NULL, linter_tag VARBINARY(32) DEFAULT '' NOT NULL, INDEX linter_page (linter_page), diff --git a/sql/tables.json b/sql/tables.json index feadad65..bc737f7e 100644 --- a/sql/tables.json +++ b/sql/tables.json @@ -41,7 +41,7 @@ "name": "linter_params", "comment": "extra parameters about the error, JSON encoded", "type": "blob", - "options": { "length": 65530, "notnull": false } + "options": { "length": 65530, "notnull": true } }, { "name": "linter_template",