1 | <?php |
||||
2 | |||||
3 | namespace SilverStripe\ExternalLinks\Controllers; |
||||
4 | |||||
5 | use SilverStripe\Control\HTTP; |
||||
6 | use SilverStripe\Core\Convert; |
||||
7 | use SilverStripe\ExternalLinks\Model\BrokenExternalPageTrackStatus; |
||||
8 | use SilverStripe\ExternalLinks\Jobs\CheckExternalLinksJob; |
||||
9 | use SilverStripe\ExternalLinks\Tasks\CheckExternalLinksTask; |
||||
10 | use SilverStripe\Control\Controller; |
||||
11 | use Symbiote\QueuedJobs\Services\QueuedJobService; |
||||
0 ignored issues
–
show
|
|||||
12 | |||||
13 | class CMSExternalLinksController extends Controller |
||||
14 | { |
||||
15 | |||||
16 | private static $allowed_actions = [ |
||||
0 ignored issues
–
show
|
|||||
17 | 'getJobStatus', |
||||
18 | 'start' |
||||
19 | ]; |
||||
20 | |||||
21 | /** |
||||
22 | * Respond to Ajax requests for info on a running job |
||||
23 | * |
||||
24 | * @return string JSON string detailing status of the job |
||||
25 | */ |
||||
26 | public function getJobStatus() |
||||
27 | { |
||||
28 | // Set headers |
||||
29 | HTTP::set_cache_age(0); |
||||
0 ignored issues
–
show
The function
SilverStripe\Control\HTTP::set_cache_age() has been deprecated: 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
30 | HTTP::add_cache_headers($this->response); |
||||
0 ignored issues
–
show
The function
SilverStripe\Control\HTTP::add_cache_headers() has been deprecated: 4.2.0:5.0.0 Headers are added automatically by HTTPCacheControlMiddleware instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
31 | $this->response |
||||
32 | ->addHeader('Content-Type', 'application/json') |
||||
33 | ->addHeader('Content-Encoding', 'UTF-8') |
||||
34 | ->addHeader('X-Content-Type-Options', 'nosniff'); |
||||
35 | |||||
36 | // Format status |
||||
37 | $track = BrokenExternalPageTrackStatus::get_latest(); |
||||
38 | if ($track) { |
||||
0 ignored issues
–
show
|
|||||
39 | return json_encode([ |
||||
40 | 'TrackID' => $track->ID, |
||||
41 | 'Status' => $track->Status, |
||||
42 | 'Completed' => $track->getCompletedPages(), |
||||
43 | 'Total' => $track->getTotalPages() |
||||
44 | ]); |
||||
45 | } |
||||
46 | } |
||||
47 | |||||
48 | |||||
49 | /** |
||||
50 | * Starts a broken external link check |
||||
51 | */ |
||||
52 | public function start() |
||||
53 | { |
||||
54 | // return if the a job is already running |
||||
55 | $status = BrokenExternalPageTrackStatus::get_latest(); |
||||
56 | if ($status && $status->Status == 'Running') { |
||||
57 | return; |
||||
58 | } |
||||
59 | |||||
60 | // Create a new job |
||||
61 | if (class_exists(QueuedJobService::class)) { |
||||
62 | // Force the creation of a new run |
||||
63 | BrokenExternalPageTrackStatus::create_status(); |
||||
64 | $checkLinks = new CheckExternalLinksJob(); |
||||
65 | singleton(QueuedJobService::class)->queueJob($checkLinks); |
||||
66 | } else { |
||||
67 | //TODO this hangs as it waits for the connection to be released |
||||
68 | // should return back and continue processing |
||||
69 | // http://us3.php.net/manual/en/features.connection-handling.php |
||||
70 | $task = CheckExternalLinksTask::create(); |
||||
71 | $task->runLinksCheck(); |
||||
72 | } |
||||
73 | } |
||||
74 | } |
||||
75 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths