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 | use SilverStripe\Dev\SapphireTest; |
||
4 | use SilverStripe\ORM\DataObject; |
||
5 | use Symbiote\QueuedJobs\Tests\ScheduledExecutionTest\TestScheduledDataObject; |
||
6 | |||
7 | /** |
||
8 | * @author [email protected] |
||
9 | * @license BSD License http://silverstripe.org/bsd-license/ |
||
10 | */ |
||
11 | class ScheduledExecutionTest extends SapphireTest |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | /** |
||
14 | * We need the DB for this test |
||
15 | * |
||
16 | * @var bool |
||
17 | */ |
||
18 | protected $usesDatabase = true; |
||
19 | |||
20 | /** |
||
21 | * {@inheritDoc} |
||
22 | * @var array |
||
23 | */ |
||
24 | protected static $extra_dataobjects = array( |
||
25 | TestScheduledDataObject::class |
||
26 | ); |
||
27 | |||
28 | public function testScheduledExecutionTimes() |
||
29 | { |
||
30 | $test = new TestScheduledDataObject; |
||
31 | |||
32 | $test->Title = 'Test execute of stuff'; |
||
0 ignored issues
–
show
The property
Title does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
33 | $test->write(); |
||
34 | |||
35 | $test->FirstExecution = '1980-09-22 09:15:00'; |
||
0 ignored issues
–
show
The property
FirstExecution does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
36 | $test->ExecuteEvery = 'Hour'; |
||
0 ignored issues
–
show
The property
ExecuteEvery does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
37 | |||
38 | $test->write(); |
||
39 | |||
40 | // should now have a job |
||
41 | $this->assertTrue($test->ScheduledJobID > 0, 'Scheduled job has not been created'); |
||
0 ignored issues
–
show
The property
ScheduledJobID does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
42 | |||
43 | $jobId = $test->ScheduledJobID; |
||
0 ignored issues
–
show
The property
ScheduledJobID does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
44 | |||
45 | // execute said job |
||
46 | $job = $test->ScheduledJob(); |
||
0 ignored issues
–
show
The method
ScheduledJob does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
47 | |||
48 | $job->execute(); |
||
49 | |||
50 | // reload the test object and make sure its job has now changed |
||
51 | $test = DataObject::get_by_id(TestScheduledDataObject::class, $test->ID); |
||
52 | |||
53 | $this->assertNotEquals($test->ScheduledJobID, $jobId); |
||
54 | $this->assertEquals('EXECUTED', $test->Message); |
||
55 | } |
||
56 | |||
57 | public function testScheduledExecutionInterval() |
||
58 | { |
||
59 | $test = new TestScheduledDataObject; |
||
60 | |||
61 | $test->Title = 'Test execute at custom interval sizes'; |
||
0 ignored issues
–
show
The property
Title does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
62 | $test->write(); |
||
63 | |||
64 | $test->FirstExecution = '1980-09-22 09:15:00'; |
||
0 ignored issues
–
show
The property
FirstExecution does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
65 | $test->ExecuteEvery = 'Minute'; |
||
0 ignored issues
–
show
The property
ExecuteEvery does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
66 | |||
67 | $test->write(); |
||
68 | |||
69 | // should now have a job |
||
70 | $this->assertTrue($test->ScheduledJobID > 0, 'Scheduled job has not been created'); |
||
0 ignored issues
–
show
The property
ScheduledJobID does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
71 | // should default the ExecuteInterval |
||
72 | $this->assertEquals(1, $test->ExecuteInterval, 'ExecuteInterval did not default to 1'); |
||
0 ignored issues
–
show
The property
ExecuteInterval does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
73 | |||
74 | // should check the interval in code also |
||
75 | $test->ExecuteInterval = 0; |
||
0 ignored issues
–
show
The property
ExecuteInterval does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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. ![]() |
|||
76 | $test->write(); |
||
77 | |||
78 | $jobId = $test->ScheduledJobID; |
||
0 ignored issues
–
show
The property
ScheduledJobID does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> . 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 | // execute said job |
||
81 | $job = $test->ScheduledJob(); |
||
0 ignored issues
–
show
The method
ScheduledJob does not exist on object<Symbiote\QueuedJo...estScheduledDataObject> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
82 | $job->execute(); |
||
83 | |||
84 | // reload the test object and make sure its job has now changed |
||
85 | $test = DataObject::get_by_id(TestScheduledDataObject::class, $test->ID); |
||
86 | |||
87 | $this->assertNotEquals($test->ScheduledJobID, $jobId); |
||
88 | $this->assertEquals('EXECUTED', $test->Message); |
||
89 | |||
90 | $job = $test->ScheduledJob(); |
||
91 | |||
92 | // should reschedule in 1 minute time |
||
93 | $expectedMinutes = date('i', time()); |
||
94 | $expectedMinutes = intval($expectedMinutes, 10); |
||
95 | if ($expectedMinutes + 1 > 59) { // Wrap around the hour |
||
96 | $expectedMinutes = $expectedMinutes - 59; |
||
97 | } |
||
98 | $scheduledMinutes = substr($job->StartAfter, 14, 2); |
||
99 | $scheduledMinutes = intval($scheduledMinutes, 10); |
||
100 | |||
101 | $this->assertEquals($expectedMinutes + 1, $scheduledMinutes, 'Did not reschedule 1 minute later'); |
||
102 | |||
103 | // test a custom interval of 3 minutes |
||
104 | |||
105 | $test->ExecuteInterval = 3; |
||
106 | $test->write(); |
||
107 | |||
108 | $job = $test->ScheduledJob(); |
||
109 | $job->execute(); |
||
110 | |||
111 | $test = DataObject::get_by_id(TestScheduledDataObject::class, $test->ID); |
||
112 | |||
113 | $job = $test->ScheduledJob(); |
||
114 | |||
115 | // should reschedule in 3 minutes time |
||
116 | $expectedMinutes = date('i', time()); |
||
117 | $expectedMinutes = intval($expectedMinutes, 10); |
||
118 | if ($expectedMinutes + 3 > 59) { |
||
119 | $expectedMinutes = $expectedMinutes - 59; |
||
120 | } |
||
121 | $scheduledMinutes = substr($job->StartAfter, 14, 2); |
||
122 | $scheduledMinutes = intval($scheduledMinutes, 10); |
||
123 | |||
124 | $this->assertEquals($expectedMinutes + 3, $scheduledMinutes, 'Did not reschedule 3 minutes later'); |
||
125 | } |
||
126 | } |
||
127 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.