diff --git a/extension.json b/extension.json index 070a6994..e3114213 100644 --- a/extension.json +++ b/extension.json @@ -27,10 +27,13 @@ "HookHandlers": { "main": { "class": "MediaWiki\\Linter\\Hooks" + }, + "schema": { + "class": "MediaWiki\\Linter\\SchemaHooks" } }, "Hooks": { - "LoadExtensionSchemaUpdates": "main", + "LoadExtensionSchemaUpdates": "schema", "BeforePageDisplay": "main", "APIQuerySiteInfoGeneralInfo": "main", "InfoAction": "main", diff --git a/includes/Hooks.php b/includes/Hooks.php index b4b33274..8558a9ff 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -22,13 +22,11 @@ namespace MediaWiki\Linter; use ApiQuerySiteinfo; use Content; -use DatabaseUpdater; use IContextSource; use MediaWiki\Api\Hook\APIQuerySiteInfoGeneralInfoHook; use MediaWiki\Hook\BeforePageDisplayHook; use MediaWiki\Hook\InfoActionHook; use MediaWiki\Hook\ParserLogLinterDataHook; -use MediaWiki\Installer\Hook\LoadExtensionSchemaUpdatesHook; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use MediaWiki\Page\Hook\RevisionFromEditCompleteHook; @@ -45,58 +43,10 @@ class Hooks implements APIQuerySiteInfoGeneralInfoHook, BeforePageDisplayHook, InfoActionHook, - LoadExtensionSchemaUpdatesHook, ParserLogLinterDataHook, RevisionFromEditCompleteHook, WikiPageDeletionUpdatesHook { - /** - * @param DatabaseUpdater $updater - */ - public function onLoadExtensionSchemaUpdates( $updater ) { - $dbType = $updater->getDB()->getType(); - if ( $dbType === 'mysql' ) { - $updater->addExtensionTable( 'linter', - dirname( __DIR__ ) . '/sql/tables-generated.sql' - ); - $updater->addExtensionField( 'linter', 'linter_namespace', - dirname( __DIR__ ) . '/sql/patch-linter-add-namespace.sql' - ); - $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' - ); - $updater->addExtensionField( 'linter', 'linter_namespace', - dirname( __DIR__ ) . '/sql/sqlite/patch-linter-add-namespace.sql' - ); - $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' - ); - $updater->addExtensionField( 'linter', 'linter_namespace', - dirname( __DIR__ ) . '/sql/postgres/patch-linter-add-namespace.sql' - ); - $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' - ); - } - } - /** * Hook: BeforePageDisplay * diff --git a/includes/SchemaHooks.php b/includes/SchemaHooks.php new file mode 100644 index 00000000..a3f58ec6 --- /dev/null +++ b/includes/SchemaHooks.php @@ -0,0 +1,73 @@ +getDB()->getType(); + if ( $dbType === 'mysql' ) { + $updater->addExtensionTable( 'linter', + dirname( __DIR__ ) . '/sql/tables-generated.sql' + ); + $updater->addExtensionField( 'linter', 'linter_namespace', + dirname( __DIR__ ) . '/sql/patch-linter-add-namespace.sql' + ); + $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' + ); + $updater->addExtensionField( 'linter', 'linter_namespace', + dirname( __DIR__ ) . '/sql/sqlite/patch-linter-add-namespace.sql' + ); + $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' + ); + $updater->addExtensionField( 'linter', 'linter_namespace', + dirname( __DIR__ ) . '/sql/postgres/patch-linter-add-namespace.sql' + ); + $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' + ); + } + } +}