Skip to content

Commit

Permalink
Merge branch '4.2' into 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Nov 7, 2018
2 parents ce4e395 + 937a347 commit 7a989c3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
8 changes: 8 additions & 0 deletions _config/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
Name: queuedjobstests
---
SilverStripe\Core\Injector\Injector:
SilverStripe\Dev\State\SapphireTestState:
properties:
States:
queuedjobsstate: '%$Symbiote\QueuedJobs\Dev\State\QueuedJobsTestState'
37 changes: 37 additions & 0 deletions src/Dev/State/QueuedJobsTestState.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Symbiote\QueuedJobs\Dev\State;

use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Dev\State\TestState;
use Symbiote\QueuedJobs\Services\QueuedJobService;

class QueuedJobsTestState implements TestState
{
/**
* Never run the shutdown handler during unit tests
*
* @param SapphireTest $test
*/
public function setUp(SapphireTest $test)
{

Config::modify()->set(QueuedJobService::class, 'use_shutdown_function', false);
}

public function tearDown(SapphireTest $test)
{
// noop
}

public function setUpOnce($class)
{
// noop
}

public function tearDownOnce($class)
{
// noop
}
}
2 changes: 1 addition & 1 deletion src/QJUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
Expand Down
10 changes: 2 additions & 8 deletions src/Services/QueuedJobService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7a989c3

Please sign in to comment.