Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit 30688d9

Browse files
committed
Use correct script paths when launching via autorun
The background script launching now checks where it's being run from, rather than just assuming that DOCUMENT_ROOT will always be available. This stops `autorun.php` from attempting to start `/scripts/*`, which doesn't exist.
1 parent 6a7ef2e commit 30688d9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/Utils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ public static function getFILES(): Map<string, array<string, mixed>> {
108108
return new Map($_FILES);
109109
}
110110

111+
public static function get_src_root() : string {
112+
return preg_replace(':/src/.*$:', '/src', __DIR__);
113+
}
114+
111115
public static function redirect(string $location): void {
112116
header('Location: '.$location);
113117
}

src/models/Level.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ public static function getBasesResponses(
12841284
// Bases processing and scoring.
12851285
public static async function genBaseScoring(): Awaitable<void> {
12861286
Utils::logMessage('Starting background script: bases');
1287-
$document_root = must_have_string(Utils::getSERVER(), 'DOCUMENT_ROOT');
1287+
$document_root = Utils::get_src_root();
12881288
$cmd =
12891289
'hhvm -vRepo.Central.Path=/var/run/hhvm/.hhvm.hhbc_bases '.
12901290
$document_root.

src/models/Progressive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private static function progressiveFromRow(
147147
// Kick off the progressive scoreboard in the background.
148148
public static async function genRun(): Awaitable<void> {
149149
Utils::logMessage('Starting background script: progressive scoreboard');
150-
$document_root = must_have_string(Utils::getSERVER(), 'DOCUMENT_ROOT');
150+
$document_root = Utils::get_src_root();
151151
$cmd =
152152
'hhvm -vRepo.Central.Path=/var/run/hhvm/.hhvm.hhbc_progressive '.
153153
$document_root.

0 commit comments

Comments
 (0)