Skip to content

Commit

Permalink
#9823 add missing current working directory restoration in shutdown f…
Browse files Browse the repository at this point in the history
…unction
  • Loading branch information
touhidurabir committed Aug 1, 2024
1 parent 1b608bb commit 3d08774
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion classes/core/PKPQueueProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ public function runJobInQueue(): void
public function boot()
{
if (Config::getVar('queues', 'job_runner', true)) {
register_shutdown_function(function () {
$currentWorkingDir = getcwd();
register_shutdown_function(function () use ($currentWorkingDir) {

// restore the current working directory
// see: https://www.php.net/manual/en/function.register-shutdown-function.php#refsect1-function.register-shutdown-function-notes
chdir($currentWorkingDir);

// As this runs at the current request's end but the 'register_shutdown_function' registered
// at the service provider's registration time at application initial bootstrapping,
// need to check the maintenance status within the 'register_shutdown_function'
Expand Down
2 changes: 1 addition & 1 deletion jobs/testJobs/TestJobFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public function __construct()
*/
public function handle(): void
{
throw new Exception('cli.test.job');
throw new Exception('Test failure job');
}
}
1 change: 1 addition & 0 deletions jobs/testJobs/TestJobSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ public function __construct()
*/
public function handle(): void
{
error_log('Test success job');
}
}

0 comments on commit 3d08774

Please sign in to comment.