User:😂/maintenance-work

Bug 19133 is a tracking bug to clean up the maintenance scripts (which are currently a gigantic mess). The maintenance-work branch was created to fix this.

Overall goals
The overall goal of this project is to improve the overall situation of the maintenance directory. Right now, things are unorganized, undocumented and do not follow any real standard. As a result, scripts are hard to maintain and support. The maintenance-work branch aims to fill the following goals: It would be nice at some point to have all of this clean & standardized to a point where an extension like Maintenance (not to be confused with Maintenance.php, the future framework...) can work without major drawbacks. In addition, the rewrite is not looking to work with any of the following:
 * Standardize - All supported maintenance scripts should follow the standards outlined in the official docs. In addition, scripts should follow MW coding conventions with variable naming
 * Documentation - All maintenance scripts should have a proper description, as well as documentation of all parameters. In addition, appropriate code documentation needs to exist for the auto-generated code docs.
 * Cleanup - Some scripts are outdated, these need to be clearly marked as such or removed.
 * Bugfixing - There's a short list of filed bugs for maintenance scripts. Some of these can be easily fixed while we're already under the hood.
 * The update/install process. Tim was looking at a rewrite/cleanup here eventually, and I'm not looking to step on toes.
 * Database abstraction. Where quick fixes can be done, they will be integrated. However, the maintainers of the different database ports should be on top of fixing broken SQL for their interfaces.

Future of commandLine.inc
commandLine.inc will not be going away. Many third party sites may very well still depend on functionality that commandLine.inc does provide. As such, it will be kept as-is for backward compatibility. The file will be marked as deprecated and will not continue to see the same level of support/bug fixing as the newer Maintenance interface.

Bugzilla
The following bugs will be marked FIXED when the maintenance-work branch is integrated to trunk:


 * 19133 - Maintenance script cleanup


 * 16322 - Allow maint scripts to accept DB user/pass over input or params if no AdminSettings.php
 * 18768 - Remove AdminSettings.php from MediaWiki core
 * 19157 - createAndPromote error on bad password
 * 18855 - require commandLine.inc properly (will be INVALID, commandLine.inc will be phased out)
 * 18930 - initStats does not refresh active_users count

Todo/Fixme

 * Handle param validation at Maintenance level, rather than making subclasses control this
 * Kinda in place? We do validate required params and make sure they have values, but we don't do type checking.
 * Split WMF-specific scripts to an extension?
 * Make help work for -help, not just --help and help as an arg.

Outstanding questions
These are things that I still need Brion/Tim/somebody's input on, as I need info about how the WMF maintenance environment works
 * Am I right in understanding that $wgUseNormalUser means to use the normal Wiki DB user, rather than the super user? Could this safely be deprecated in favor of a more OOP approach?
 * Is $wgUseRootUser actually used anywhere?
 * Can the scripts in "to be deprecated" be safely deleted?

Scripts
The following scripts have been checked and sorted into the following lists. If a maintenance script is not here, it has not been reviewed.

WMF-specific

 * addwiki.php
 * dumpInterwiki.php
 * ourusers.php
 * rebuildInterwiki.php
 * renamewiki.php

To be ported

 * All of the TableCleanup/fiveUpgrade-related scripts. Kinda tied to the update stuff though? Needs more poking.
 * All of the rebuild* scripts
 * All of the maint scripts in maintenance/language
 * Extensions?

Fully ported

 * benchmarkPurge.php

Fully ported && tested

 * attachLatest.php
 * eval.php
 * changePassword.php
 * checkAutoLoader.php
 * checkImages.php
 * checkUsernames.php
 * clear_interwiki_cache.php
 * clear_stats.php
 * createAndPromote.php
 * deleteBatch.php
 * deleteRevision.php
 * getSlaveServer.php
 * moveBatch.php
 * nextJobDB.php
 * purgeOldText.php
 * reassignEdits.php
 * refreshImageCount.php
 * renameDbPrefix.php
 * renderDump.php
 * showJobs.php
 * stats.php
 * updateSearchIndex.php
 * waitForSlave.php

To be deprecated

 * apache-ampersand.diff (doesn't seem to ever have been used)
 * attribute.php (in favor of reassignEdits.php)
 * namespace2sql.php (doesn't seem to ever have been used)
 * archives/upgradeWatchlist.php (ridiculously outdated, unused)
 * archives/rebuildRecentchanges.inc (same)

Removable .inc files
The following .inc files are being deleted because their code was merged to the appropriate maintenance script: The following files had functionality merged into Maintenance.php
 * initStats, reassignEdits, updateArticleCount, updateSearchIndex
 * purgeOldText