This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Symbiote\QueuedJobs\Tasks; |
||
4 | |||
5 | use SilverStripe\Core\ClassInfo; |
||
6 | use SilverStripe\Dev\BuildTask; |
||
7 | use Symbiote\QueuedJobs\Services\AbstractQueuedJob; |
||
8 | use Symbiote\QueuedJobs\Services\QueuedJob; |
||
9 | |||
10 | /** |
||
11 | * A task that can be used to create a queued job. |
||
12 | * |
||
13 | * Useful to hook a queued job in to place that needs to exist if it doesn't already. |
||
14 | * |
||
15 | * If no name is given, it creates a demo dummy job to help test that things |
||
16 | * are set up and working |
||
17 | * |
||
18 | * @author Marcus Nyeholt <[email protected]> |
||
19 | * @license BSD http://silverstripe.org/bsd-license/ |
||
20 | */ |
||
21 | class CreateQueuedJobTask extends BuildTask |
||
22 | { |
||
23 | /** |
||
24 | * {@inheritDoc} |
||
25 | * @var string |
||
26 | */ |
||
27 | private static $segment = 'CreateQueuedJobTask'; |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
![]() |
|||
28 | |||
29 | /** |
||
30 | * @return string |
||
31 | */ |
||
32 | public function getDescription() |
||
33 | { |
||
34 | return _t( |
||
35 | 'CreateQueuedJobTask.Description', |
||
36 | 'A task used to create a queued job. Pass the queued job class name as the "name" parameter, pass an optional "start" parameter (parseable by strtotime) to set a start time for the job.' |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param SS_HTTPRequest $request |
||
42 | */ |
||
43 | public function run($request) |
||
44 | { |
||
45 | if (isset($request['name']) && ClassInfo::exists($request['name'])) { |
||
46 | $clz = $request['name']; |
||
47 | $job = new $clz; |
||
48 | } else { |
||
49 | $job = new DummyQueuedJob(mt_rand(10, 100)); |
||
50 | } |
||
51 | |||
52 | if (isset($request['start'])) { |
||
53 | $start = strtotime($request['start']); |
||
54 | $now = time(); |
||
55 | if ($start >= $now) { |
||
56 | $friendlyStart = date('Y-m-d H:i:s', $start); |
||
57 | echo "Job ".$request['name']. " queued to start at: <b>".$friendlyStart."</b>"; |
||
58 | singleton('Symbiote\\QueuedJobs\\Services\\QueuedJobService')->queueJob($job, $start); |
||
59 | } else { |
||
60 | echo "'start' parameter must be a date/time in the future, parseable with strtotime"; |
||
61 | } |
||
62 | } else { |
||
63 | echo "Job Queued"; |
||
64 | singleton('Symbiote\\QueuedJobs\\Services\\QueuedJobService')->queueJob($job); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | |||
69 | class DummyQueuedJob extends AbstractQueuedJob implements QueuedJob |
||
0 ignored issues
–
show
|
|||
70 | { |
||
71 | /** |
||
72 | * @param int $number |
||
73 | */ |
||
74 | public function __construct($number = 0) |
||
75 | { |
||
76 | if ($number) { |
||
77 | $this->startNumber = $number; |
||
0 ignored issues
–
show
The property
startNumber does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
78 | $this->totalSteps = $this->startNumber; |
||
0 ignored issues
–
show
The property
startNumber does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
79 | } |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getTitle() |
||
86 | { |
||
87 | return "Some test job for ".$this->startNumber.' seconds'; |
||
0 ignored issues
–
show
The property
startNumber does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getJobType() |
||
94 | { |
||
95 | return QueuedJob::QUEUED; |
||
96 | } |
||
97 | |||
98 | public function setup() |
||
99 | { |
||
100 | // just demonstrating how to get a job going... |
||
101 | $this->totalSteps = $this->startNumber; |
||
0 ignored issues
–
show
The property
startNumber does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
102 | $this->times = array(); |
||
0 ignored issues
–
show
The property
times does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
103 | } |
||
104 | |||
105 | View Code Duplication | public function process() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
106 | { |
||
107 | $times = $this->times; |
||
0 ignored issues
–
show
The property
times does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
108 | // needed due to quirks with __set |
||
109 | $times[] = date('Y-m-d H:i:s'); |
||
110 | $this->times = $times; |
||
0 ignored issues
–
show
The property
times does not exist on object<Symbiote\QueuedJobs\Tasks\DummyQueuedJob> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
111 | |||
112 | $this->addMessage("Updated time to " . date('Y-m-d H:i:s')); |
||
113 | sleep(1); |
||
114 | |||
115 | // make sure we're incrementing |
||
116 | $this->currentStep++; |
||
117 | |||
118 | // if ($this->currentStep > 1) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
119 | // $this->currentStep = 1; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
120 | // } |
||
121 | |||
122 | // and checking whether we're complete |
||
123 | if ($this->currentStep >= $this->totalSteps) { |
||
124 | $this->isComplete = true; |
||
125 | } |
||
126 | } |
||
127 | } |
||
128 |