Skip to content

Commit

Permalink
fix(worker-script) unset globals before run
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Nov 25, 2023
1 parent 014a69e commit beffe0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Process/Worker/worker-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
use lucatume\WPBrowser\Process\Protocol\Response;
use lucatume\WPBrowser\Process\SerializableThrowable;

$processSrcRoot = __DIR__ . '/..';
require_once $processSrcRoot . '/Protocol/Parser.php';
require_once $processSrcRoot . '/Protocol/Control.php';
require_once $processSrcRoot . '/Protocol/Request.php';
require_once $processSrcRoot . '/Protocol/ProtocolException.php';
require_once __DIR__ . '/../Protocol/Parser.php';
require_once __DIR__ . '/../Protocol/Control.php';
require_once __DIR__ . '/../Protocol/Request.php';
require_once __DIR__ . '/../Protocol/ProtocolException.php';

try {
if (!isset($argv[1])) {
Expand All @@ -22,8 +21,9 @@
}

$request = Request::fromPayload($payload);
$serializableClosure = $request->getSerializableClosure();
$returnValue = $serializableClosure();
$_wpBrowserWorkerClosure = $request->getSerializableClosure();
unset($payload, $request);
$returnValue = $_wpBrowserWorkerClosure();
} catch (Throwable $throwable) {
$returnValue = new SerializableThrowable($throwable);
}
Expand Down
1 change: 1 addition & 0 deletions src/TestCase/WPTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WPTestCase extends Unit
// Additional globals.
'_wp_registered_theme_features',
// wp-browser
'_wpBrowserWorkerClosure',
'_wpTestsBackupGlobals',
'_wpTestsBackupGlobalsExcludeList',
'_wpTestsBackupStaticAttributes',
Expand Down

0 comments on commit beffe0d

Please sign in to comment.