patchdemo1
-
- Patch Demo
(admin)
- Alice
- Bob
- Mallory
(blocked)
-
- EOT ),
- 'helpInline' => true,
- ]
- ),
- ]
-] );
-
-echo '';
-
-echo '';
-
if ( $patches ) {
$patches = array_map( 'trim', preg_split( "/\n|\|/", $patches ) );
} else {
@@ -176,7 +77,6 @@ function set_progress( float $pc, string $label ) {
$o = 'CURRENT_REVISION';
}
$data = gerrit_query( "changes/?q=change:$query&o=LABELS&o=$o", true );
- check_connection();
if ( count( $data ) === 0 ) {
$patch = htmlentities( $patch );
@@ -220,26 +120,12 @@ function set_progress( float $pc, string $label ) {
$config[ 'requireVerified' ] &&
( $data[0]['labels']['Verified']['approved']['_account_id'] ?? null ) !== 75 &&
// Admin override
- !( $canAdmin && isset( $_POST['adminVerified'] ) )
+ !( $canAdmin && !empty( getenv( 'adminVerified' ) ) )
) {
// The patch doesn't have V+2, check if the uploader is trusted
$uploaderId = $data[0]['revisions'][$revision]['uploader']['_account_id'];
$uploader = gerrit_query( 'accounts/' . $uploaderId, true );
- check_connection();
if ( !is_trusted_user( $uploader['email'] ) ) {
- if ( $canAdmin ) {
- echo '';
- }
abandon(
"Patch must be approved (Verified+2) by jenkins-bot, or uploaded by a trusted user." .
( can_admin() ?
@@ -281,7 +167,6 @@ function set_progress( float $pc, string $label ) {
// Look at all commits in this patch's tree for cross-repo dependencies to add
$data = gerrit_query( "changes/$id/revisions/$revision/related", true );
- check_connection();
// Ancestor commits only, not descendants
$foundCurr = false;
foreach ( $data['changes'] as $change ) {
@@ -294,7 +179,6 @@ function set_progress( float $pc, string $label ) {
foreach ( $relatedChanges as [ $c, $r ] ) {
$data = gerrit_query( "changes/$c/revisions/$r/commit", true );
- check_connection();
preg_match_all( '/^Depends-On: (.+)$/m', $data['message'], $m );
foreach ( $m[1] as $changeid ) {
@@ -319,17 +203,17 @@ function set_progress( float $pc, string $label ) {
// Choose repositories to enable
$repos = get_repo_data();
-if ( $_POST['preset'] === 'custom' ) {
- $allowedRepos = $_POST['repos'];
+if ( getenv( 'preset' ) === 'custom' ) {
+ $allowedRepos = explode( '|', getenv( 'repos' ) );
} else {
- $allowedRepos = get_repo_presets()[ $_POST['preset'] ];
+ $allowedRepos = get_repo_presets()[ getenv( 'preset' ) ];
}
// Always include repos we are trying to patch (#401)
$allowedRepos = array_merge( $allowedRepos, $usedRepos );
-$useProxy = !empty( $_POST['proxy'] );
-$useInstantCommons = !empty( $_POST['instantCommons' ] );
+$useProxy = !empty( getenv( 'proxy' ) );
+$useInstantCommons = !empty( getenv( 'instantCommons' ) );
// When proxying, always enable MobileFrontend and its content provider
if ( $useProxy ) {
// Doesn't matter if this appears twice
@@ -337,7 +221,7 @@ function set_progress( float $pc, string $label ) {
$allowedRepos[] = 'mediawiki/extensions/MobileFrontendContentProvider';
}
if ( $useInstantCommons ) {
- if ( $_POST['instantCommonsMethod'] === 'quick' ) {
+ if ( getenv( 'instantCommonsMethod' ) === 'quick' ) {
$allowedRepos[] = 'mediawiki/extensions/QuickInstantCommons';
$useInstantCommons = false;
}
@@ -385,7 +269,6 @@ function set_progress( float $pc, string $label ) {
list( $t, $r, $p ) = $matches;
$data = gerrit_query( "changes/$r/revisions/$p/commit", true );
- check_connection();
if ( $data ) {
$t = $t . ': ' . $data[ 'subject' ];
get_linked_tasks( $data['message'], $linkedTasks );
@@ -418,7 +301,6 @@ function set_progress( float $pc, string $label ) {
foreach ( $repos as $source => $target ) {
set_progress( $repoProgress, "Updating repositories ($n/$repoCount)..." );
- check_connection();
$error = shell_echo( __DIR__ . '/new/updaterepos.sh',
$baseEnv + [
'REPO_SOURCE' => $source,
@@ -434,7 +316,6 @@ function set_progress( float $pc, string $label ) {
}
// Just creates empty folders so no need for progress update
-check_connection();
$error = shell_echo( __DIR__ . '/new/precheckout.sh', $baseEnv );
if ( $error ) {
abandon( "Could not create directories for wiki" );
@@ -448,7 +329,6 @@ function set_progress( float $pc, string $label ) {
foreach ( $repos as $source => $target ) {
set_progress( $repoProgress, "Checking out repositories ($n/$repoCount)..." );
- check_connection();
$error = shell_echo( __DIR__ . '/new/checkout.sh',
$baseEnv + [
'BRANCH' => $repoSpecificBranches[$source] ?? $branch,
@@ -466,7 +346,6 @@ function set_progress( float $pc, string $label ) {
// TODO: Make this a loop
set_progress( 60, 'Fetching submodules...' );
-check_connection();
$error = shell_echo( __DIR__ . '/new/submodules.sh', $baseEnv );
if ( $error ) {
abandon( "Could not fetch submodules" );
@@ -487,7 +366,6 @@ static function ( string $repo ) use ( $repos ): bool {
foreach ( $composerInstallRepos as $i => $repo ) {
$n = $i + 1;
set_progress( $repoProgress, "Fetching dependencies ($n/$repoCount)..." );
- check_connection();
$error = shell_echo( __DIR__ . '/new/composerinstall.sh',
$baseEnv + [
// Variable used by composer itself, not our script
@@ -504,7 +382,6 @@ static function ( string $repo ) use ( $repos ): bool {
set_progress( 65, 'Installing your wiki...' );
-check_connection();
$error = shell_echo( __DIR__ . '/new/install.sh',
$baseEnv + [
'WIKINAME' => $wikiName,
@@ -525,7 +402,6 @@ static function ( string $repo ) use ( $repos ): bool {
foreach ( $commands as $i => $command ) {
$n = $i + 1;
set_progress( $progress, "Fetching and applying patches ($n/$count)..." );
- check_connection();
$error = shell_echo( $command[1], $baseEnv + $command[0] );
if ( $error ) {
abandon( "Could not apply patch {$patchesApplied[$i]}" );
@@ -535,7 +411,6 @@ static function ( string $repo ) use ( $repos ): bool {
set_progress( 90, 'Setting up wiki content...' );
-check_connection();
$error = shell_echo( __DIR__ . '/new/postinstall.sh',
$baseEnv + [
'MAINPAGE' => $mainPage,
@@ -577,5 +452,3 @@ static function ( string $repo ) use ( $repos ): bool {
wiki_set_time_to_create( $wiki, $timeToCreate );
set_progress( 100, 'All done! Wiki created in ' . format_duration( $timeToCreate ) . '.' );
-
-echo '
';
diff --git a/setup.sh b/setup.sh
index d177437e..b2367770 100755
--- a/setup.sh
+++ b/setup.sh
@@ -30,6 +30,9 @@ sudo -u www-data mkdir composer
# Create folder for wikis
sudo -u www-data mkdir wikis
+# Create folder for wiki creation logs
+sudo -u www-data mkdir logs
+
# Create a database user that is allowed to create databases for each wiki,
# and the central patchdemo database
sudo mysql -u root --password='' < sql/user.sql
diff --git a/start.php b/start.php
new file mode 100644
index 00000000..812c1124
--- /dev/null
+++ b/start.php
@@ -0,0 +1,125 @@
+username : '';
+ $branchDesc = preg_replace( '/^origin\//', '', $_POST['branch'] );
+
+ // Start creatig the wiki
+ $env = [
+ 'wiki' => $wiki,
+ 'creator' => $creator,
+ 'canAdmin' => can_admin(),
+ 'branchDesc' => $branchDesc,
+
+ 'announce' => $_POST['announce'] ?? '',
+ 'branch' => $_POST['branch'],
+ 'instantCommons' => $_POST['instantCommons'],
+ 'instantCommonsMethod' => $_POST['instantCommonsMethod'],
+ 'language' => $_POST['language'],
+ 'patches' => $_POST['patches'],
+ 'preset' => $_POST['preset'],
+ 'proxy' => $_POST['proxy'] ?? '',
+ 'repos' => implode( '|', $_POST['repos'] ),
+
+ 'adminVerified' => $_POST['adminVerified'] ?? '',
+
+ 'server' => get_server(),
+ 'serverPath' => get_server_path(),
+ ];
+
+ $process = Process::fromShellCommandline(
+ 'php new.php >> logs/' . $wiki . '.html',
+ null,
+ $env
+ );
+ $process->setTimeout( null );
+ $process->start();
+
+ // Create an entry for the wiki before we have resolved patches.
+ // Will be updated later.
+ insert_wiki_data( $wiki, $creator, time(), $branchDesc );
+
+ // If we terminate this script (start.php) immediately, the process above can stop (?)
+ sleep( 1 );
+}
+
+echo new OOUI\FieldsetLayout( [
+ 'label' => null,
+ 'classes' => [ 'installForm' ],
+ 'items' => [
+ new OOUI\FieldLayout(
+ new OOUI\ProgressBarWidget( [ 'progress' => 0 ] ),
+ [
+ 'align' => 'top',
+ 'label' => 'Installing...',
+ 'classes' => [ 'installProgressField' ],
+ 'infusable' => true,
+ ]
+ ),
+ new OOUI\FieldLayout(
+ new OOUI\ButtonWidget( [
+ 'label' => 'Open wiki',
+ 'flags' => [ 'progressive', 'primary' ],
+ 'href' => "wikis/$wiki/w/",
+ 'disabled' => true,
+ 'classes' => [ 'openWiki' ],
+ 'infusable' => true,
+ ] ),
+ [
+ 'align' => 'inline',
+ 'classes' => [ 'openWikiField' ],
+ 'label' => "When complete, use this button to open your wiki ($wiki)",
+ 'help' => new OOUI\HtmlSnippet( <<patchdemo1
+
+ Patch Demo
(admin)
+ Alice
+ Bob
+ Mallory
(blocked)
+
+ EOT ),
+ 'helpInline' => true,
+ ]
+ ),
+ ]
+] );
+
+if ( can_admin() ) {
+ echo '';
+}
+
+echo '';
+
+echo '';
+echo '';