diff --git a/_config/tests.yml b/_config/tests.yml new file mode 100644 index 00000000..0851062f --- /dev/null +++ b/_config/tests.yml @@ -0,0 +1,8 @@ +--- +Name: queuedjobstests +--- +SilverStripe\Core\Injector\Injector: + SilverStripe\Dev\State\SapphireTestState: + properties: + States: + queuedjobsstate: '%$Symbiote\QueuedJobs\Dev\State\QueuedJobsTestState' diff --git a/src/Dev/State/QueuedJobsTestState.php b/src/Dev/State/QueuedJobsTestState.php new file mode 100644 index 00000000..c4fce406 --- /dev/null +++ b/src/Dev/State/QueuedJobsTestState.php @@ -0,0 +1,37 @@ +set(QueuedJobService::class, 'use_shutdown_function', false); + } + + public function tearDown(SapphireTest $test) + { + // noop + } + + public function setUpOnce($class) + { + // noop + } + + public function tearDownOnce($class) + { + // noop + } +} diff --git a/src/QJUtils.php b/src/QJUtils.php index 7c41ec4b..61ecec59 100644 --- a/src/QJUtils.php +++ b/src/QJUtils.php @@ -91,7 +91,7 @@ protected function recursiveQuote($val) */ public function ajaxResponse($message, $status) { - return Convert::raw2json(array( + return json_encode(array( 'message' => $message, 'status' => $status, )); diff --git a/src/Services/QueuedJobService.php b/src/Services/QueuedJobService.php index 23a02a04..4fa7e9ec 100644 --- a/src/Services/QueuedJobService.php +++ b/src/Services/QueuedJobService.php @@ -266,14 +266,8 @@ protected function copyDescriptorToJob($jobDescriptor, $job) $messages = @unserialize($jobDescriptor->SavedJobMessages); if (!$jobData) { - // SS's convert:: function doesn't do this detection for us!! - if (function_exists('json_decode')) { - $jobData = json_decode($jobDescriptor->SavedJobData); - $messages = json_decode($jobDescriptor->SavedJobMessages); - } else { - $jobData = Convert::json2obj($jobDescriptor->SavedJobData); - $messages = Convert::json2obj($jobDescriptor->SavedJobMessages); - } + $jobData = json_decode($jobDescriptor->SavedJobData); + $messages = json_decode($jobDescriptor->SavedJobMessages); } $job->setJobData(