| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace LeKoala\DevToolkit\Tasks; |
||||||
| 4 | |||||||
| 5 | use Exception; |
||||||
| 6 | use SilverStripe\Dev\BuildTask; |
||||||
| 7 | use SilverStripe\Control\Director; |
||||||
| 8 | use LeKoala\Base\Helpers\FileHelper; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 9 | |||||||
| 10 | /** |
||||||
| 11 | */ |
||||||
| 12 | class ClearCacheFolderTask extends BuildTask |
||||||
| 13 | { |
||||||
| 14 | protected $title = "Clear cache folder"; |
||||||
| 15 | protected $description = 'Clear silverstripe-cache folder.'; |
||||||
| 16 | private static $segment = 'ClearCacheFolderTask'; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 17 | |||||||
| 18 | public function run($request) |
||||||
| 19 | { |
||||||
| 20 | $this->request = $request; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 21 | |||||||
| 22 | $folder = Director::baseFolder() . '/silverstripe-cache'; |
||||||
| 23 | $create = $_GET['create'] ?? false; |
||||||
| 24 | if (!is_dir($folder)) { |
||||||
| 25 | if ($create) { |
||||||
| 26 | mkdir($folder, 0755); |
||||||
| 27 | } else { |
||||||
| 28 | throw new Exception("silverstripe-cache folder does not exist in root"); |
||||||
| 29 | } |
||||||
| 30 | } |
||||||
| 31 | |||||||
| 32 | $result = FileHelper::rmDir($folder); |
||||||
| 33 | if ($result) { |
||||||
| 34 | $this->message("Removed $folder"); |
||||||
|
0 ignored issues
–
show
The method
message() does not exist on LeKoala\DevToolkit\Tasks\ClearCacheFolderTask. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 35 | } else { |
||||||
| 36 | $this->message("Failed to remove $folder", "error"); |
||||||
| 37 | } |
||||||
| 38 | $result = mkdir($folder, 0755); |
||||||
| 39 | if ($result) { |
||||||
| 40 | $this->message("A new folder has been created at $folder"); |
||||||
| 41 | } else { |
||||||
| 42 | $this->message("Failed to create a new folder at $folder", "error"); |
||||||
| 43 | } |
||||||
| 44 | } |
||||||
| 45 | } |
||||||
| 46 |
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