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\Core\Config\Config; |
||
5 | use SilverStripe\ORM\FieldType\DBDatetime; |
||
6 | use Symbiote\QueuedJobs\Jobs\CleanupJob; |
||
7 | |||
8 | /** |
||
9 | * @author Andrew Aitken-Fincham <[email protected]> |
||
10 | */ |
||
11 | class CleanupJobTest extends SapphireTest |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | /** |
||
14 | * {@inheritDoc} |
||
15 | * @var string |
||
16 | */ |
||
17 | protected static $fixture_file = 'CleanupJobFixture.yml'; |
||
18 | |||
19 | /** |
||
20 | * {@inheritDoc} |
||
21 | */ |
||
22 | public function setUp() |
||
23 | { |
||
24 | // Have to set a fake time here to work with |
||
25 | // the LastEdited dates in the fixture |
||
26 | DBDatetime::set_mock_now("2002-02-03 02:02:02"); |
||
27 | parent::setUp(); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | public function tearDown() |
||
34 | { |
||
35 | parent::tearDown(); |
||
36 | DBDatetime::clear_mock_now(); |
||
37 | } |
||
38 | |||
39 | View Code Duplication | public function testByDays() |
|
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. ![]() |
|||
40 | { |
||
41 | $job = new CleanupJob(); |
||
42 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_method', 'age'); |
||
43 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_value', 30); |
||
44 | Config::inst()->remove('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_statuses'); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
SilverStripe\Config\Coll...nfigCollectionInterface as the method remove() does only exist in the following implementations of said interface: SilverStripe\Config\Coll...\MemoryConfigCollection .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
45 | Config::modify()->set( |
||
46 | 'Symbiote\\QueuedJobs\\Jobs\\CleanupJob', |
||
47 | 'cleanup_statuses', |
||
48 | array('Broken', 'Complete') |
||
49 | ); |
||
50 | $job->process(); |
||
51 | $data = $job->getJobData(); |
||
52 | $this->assertContains("2 jobs cleaned up.", $data->messages[0]); |
||
53 | } |
||
54 | |||
55 | View Code Duplication | public function testByNumber() |
|
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. ![]() |
|||
56 | { |
||
57 | $job = new CleanupJob(); |
||
58 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_method', 'number'); |
||
59 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_value', 3); |
||
60 | Config::inst()->remove('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_statuses'); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
SilverStripe\Config\Coll...nfigCollectionInterface as the method remove() does only exist in the following implementations of said interface: SilverStripe\Config\Coll...\MemoryConfigCollection .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
61 | Config::modify()->set( |
||
62 | 'Symbiote\\QueuedJobs\\Jobs\\CleanupJob', |
||
63 | 'cleanup_statuses', |
||
64 | array('Broken', 'Complete') |
||
65 | ); |
||
66 | $job->process(); |
||
67 | $data = $job->getJobData(); |
||
68 | $this->assertContains("2 jobs cleaned up.", $data->messages[0]); |
||
69 | } |
||
70 | |||
71 | View Code Duplication | public function testByStatus() |
|
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. ![]() |
|||
72 | { |
||
73 | $job = new CleanupJob(); |
||
74 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_method', 'number'); |
||
75 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_value', 3); |
||
76 | Config::inst()->remove('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_statuses'); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
SilverStripe\Config\Coll...nfigCollectionInterface as the method remove() does only exist in the following implementations of said interface: SilverStripe\Config\Coll...\MemoryConfigCollection .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
77 | Config::modify()->set( |
||
78 | 'Symbiote\\QueuedJobs\\Jobs\\CleanupJob', |
||
79 | 'cleanup_statuses', |
||
80 | array('Broken', 'Complete', 'New') |
||
81 | ); |
||
82 | $job->process(); |
||
83 | $data = $job->getJobData(); |
||
84 | $this->assertContains("3 jobs cleaned up.", $data->messages[0]); |
||
85 | } |
||
86 | |||
87 | View Code Duplication | public function testNoCleanup() |
|
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. ![]() |
|||
88 | { |
||
89 | $job = new CleanupJob(); |
||
90 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_method', 'number'); |
||
91 | Config::modify()->set('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_value', 6); |
||
92 | Config::inst()->remove('Symbiote\\QueuedJobs\\Jobs\\CleanupJob', 'cleanup_statuses'); |
||
0 ignored issues
–
show
It seems like you code against a concrete implementation and not the interface
SilverStripe\Config\Coll...nfigCollectionInterface as the method remove() does only exist in the following implementations of said interface: SilverStripe\Config\Coll...\MemoryConfigCollection .
Let’s take a look at an example: interface User
{
/** @return string */
public function getPassword();
}
class MyUser implements User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
93 | Config::modify()->set( |
||
94 | 'Symbiote\\QueuedJobs\\Jobs\\CleanupJob', |
||
95 | 'cleanup_statuses', |
||
96 | array('Broken', 'Complete', 'New') |
||
97 | ); |
||
98 | $job->process(); |
||
99 | $data = $job->getJobData(); |
||
100 | $this->assertContains("No jobs to clean up.", $data->messages[0]); |
||
101 | } |
||
102 | } |
||
103 |
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.