2019-10-18 12:12:55 +00:00
|
|
|
<?php
|
|
|
|
|
2020-02-19 01:41:05 +00:00
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Maintenance;
|
|
|
|
|
|
|
|
use ForeignResourceManager;
|
|
|
|
use Maintenance;
|
|
|
|
|
|
|
|
// Security: Disable all stream wrappers and reenable individually as needed
|
|
|
|
foreach ( stream_get_wrappers() as $wrapper ) {
|
|
|
|
stream_wrapper_unregister( $wrapper );
|
|
|
|
}
|
|
|
|
// Needed by the Guzzle library for some reason
|
|
|
|
stream_wrapper_restore( 'php' );
|
|
|
|
// Needed by ForeignResourceManager to unpack TAR files
|
|
|
|
stream_wrapper_restore( 'phar' );
|
|
|
|
|
|
|
|
stream_wrapper_restore( 'file' );
|
|
|
|
$basePath = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
if ( $basePath ) {
|
|
|
|
if ( !is_dir( $basePath )
|
|
|
|
|| strpos( $basePath, '~' ) !== false
|
|
|
|
) {
|
|
|
|
die( "Bad MediaWiki install path: $basePath\n" );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$basePath = __DIR__ . '/../../..';
|
2019-10-18 12:12:55 +00:00
|
|
|
}
|
2020-02-19 01:41:05 +00:00
|
|
|
require_once "$basePath/maintenance/Maintenance.php";
|
2019-10-18 12:12:55 +00:00
|
|
|
|
2020-01-13 19:48:11 +00:00
|
|
|
class ManageForeignResources extends Maintenance {
|
2020-01-13 21:15:43 +00:00
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->requireExtension( 'DiscussionTools' );
|
|
|
|
}
|
|
|
|
|
2019-10-18 12:12:55 +00:00
|
|
|
public function execute() {
|
|
|
|
$frm = new ForeignResourceManager(
|
|
|
|
__DIR__ . '/../modules/lib/foreign-resources.yaml',
|
|
|
|
__DIR__ . '/../modules/lib'
|
|
|
|
);
|
|
|
|
return $frm->run( 'update', 'all' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-13 19:48:11 +00:00
|
|
|
$maintClass = ManageForeignResources::class;
|
2020-02-19 01:41:05 +00:00
|
|
|
|
|
|
|
$doMaintenancePath = RUN_MAINTENANCE_IF_MAIN;
|
|
|
|
if ( !( file_exists( $doMaintenancePath ) &&
|
|
|
|
realpath( $doMaintenancePath ) === realpath( "$basePath/maintenance/doMaintenance.php" ) ) ) {
|
|
|
|
die( "Bad maintenance script location: $basePath\n" );
|
|
|
|
}
|
|
|
|
|
2019-10-18 12:12:55 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|