Page MenuHomePhabricator

Overhaul how Maintenance scripts are run (especially in extensions)
Closed, DuplicatePublic

Description

// Detect $IP
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
	$IP = __DIR__ . '/../..';
}
// Require base maintenance class
require_once "$IP/maintenance/Maintenance.php";

All Maintenance scripts in extensions end up with code like this. It's messy, and it's a PITA. Even more so with things like WikimediaMaintenance

Don't know if this should be an rfc... But IMHO, we should have some sort of wrapper script, which invokes maintenance scripts, wherever they lie.

So all maintenance scripts should be in the autoloader, and then you run something like

php maintenance/run.php ScriptNameHere --arg=1 --arg2=3

I'd hazard a guess, that something like this would be further beneficial when running hhvm in repo authoritative mode, where we end up with an "all in one" type of file...

But then, at the end, we wouldn't need the block of code at the top of every extension maintenance script, Or the

require_once __DIR__ . '/Maintenance.php';

in core ones, almost randomly guessing where Maintenance.php, which is not always obviously, especially if you symlink things in.

Event Timeline

Reedy raised the priority of this task from to Needs Triage.
Reedy updated the task description. (Show Details)
Reedy subscribed.
Reedy set Security to None.

Is this RfC worthy? Or not necessary?

I'm up for a discussion on "how" scripts are invoked (wrapper script? some other magic?); I'm certainly not married to teh idea of having a wrapper runner script etc, but essentially having them "registered" (some new tracking global? Ugh. Certainly don't think doing it via reflection is the best idea either) as a maintenance script, and in the autoloader... Minimal extra overhead if they're not used, mostly an entry in the array