User:Novem Linguae/Essays/MediaWiki extension cleanup checklist

Ideas for how to methodically upgrade an old MediaWiki extension to modern standards.

If you are new to MediaWiki, try writing tests! These are safe, easy to review, and MediaWiki provides lots of good seams so you usually don't have to do refactoring before writing said tests.

PHP

 * Move any .php files not in the /includes/ or /maintenance/ folders into those folders (fixes code coverage report, is normal spot for these)
 * Comment any maintenance files that are run by Puppet cron jobs, so that people are less likely to rename them and break the cron job. Use codesearch. Example.
 * Move all phpunit tests into /unit/ and /integration/ folders, so that phpunit:unit and phpunit:integration work correctly
 * Write tests for every .php file. Get code coverage to >70% for each file. Every method with logic should have at least one test.
 * Once tests are in place, you can begin refactoring
 * Add "use" statements, so that intellisense works correctly. May need to bump the version number of the extension.
 * Add namespaces to every file
 * And change corresponding  and   statements, including in other repos
 * In extension.json, search for . Convert to HookHandlers. Example. Video tutorial.
 * Fix all deprecations (once  statements are all in place, you can see these in VS Code by opening a file and looking in the "problems" pane)
 * Linter / phpcs: make sure MediaWiki ruleset is loaded, enable any disabled rules, and fix associated errors.
 * Search for, replace with   or
 * Search for, replace with injection or  . Makes testing easier. Example.
 * Search for, convert to
 * SQL
 * Search for,  ,  ,  ,  ,  , and  . These can usually be refactored to
 * Search for   and   . These can usually be replaced with   and.
 * Replace old style SQL queries with
 * Split big classes
 * Split big methods
 * Switch to the Record/Lookup/Manager pattern

JavaScript

 * Linter / eslint: make sure MediaWiki ruleset is loaded, enable any disabled rules, and fix associated errors.
 * Migrate front ends from jquery.ui/mustache/ooui to vue/codex? Is vue/codex ready for mass deployment to non-SPA type pages?