|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Created by PhpStorm. |
|
5
|
|
|
* User: gordon |
|
6
|
|
|
* Date: 25/3/2561 |
|
7
|
|
|
* Time: 17:01 น. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Suilven\FreeTextSearch\Task; |
|
11
|
|
|
|
|
12
|
|
|
use League\CLImate\CLImate; |
|
|
|
|
|
|
13
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
|
14
|
|
|
use SilverStripe\Control\Director; |
|
15
|
|
|
use SilverStripe\Dev\BuildTask; |
|
16
|
|
|
use SilverStripe\Security\Permission; |
|
17
|
|
|
use SilverStripe\Security\Security; |
|
18
|
|
|
use SilverStripe\SiteConfig\SiteConfig; |
|
19
|
|
|
use Suilven\FreeTextSearch\Factory\BulkIndexerFactory; |
|
20
|
|
|
use Suilven\FreeTextSearch\Helper\BulkIndexingHelper; |
|
21
|
|
|
use Suilven\FreeTextSearch\Indexes; |
|
22
|
|
|
|
|
23
|
|
|
class ReindexTask extends BuildTask |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
protected $title = 'Reindex'; |
|
27
|
|
|
|
|
28
|
|
|
protected $description = 'Reindex all dataobjects referred to in indexes'; |
|
29
|
|
|
|
|
30
|
|
|
protected $enabled = true; |
|
31
|
|
|
|
|
32
|
|
|
/** @var string */ |
|
33
|
|
|
private static $segment = 'reindex'; |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Implement this method in the task subclass to |
|
40
|
|
|
* execute via the TaskRunner |
|
41
|
|
|
* |
|
42
|
|
|
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint |
|
43
|
|
|
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint |
|
44
|
|
|
* @param \SilverStripe\Control\HTTPRequest $request |
|
45
|
|
|
* @return \SilverStripe\Control\HTTPResponse|void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function run($request) |
|
48
|
|
|
{ |
|
49
|
|
|
$climate = new CLImate(); |
|
50
|
|
|
|
|
51
|
|
|
// check this script is being run by admin |
|
52
|
|
|
$canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); |
|
53
|
|
|
if (!$canAccess) { |
|
54
|
|
|
return Security::permissionFailure(null); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
/** @var string $indexName */ |
|
59
|
|
|
$indexName = $request->getVar('index'); |
|
60
|
|
|
|
|
61
|
|
|
$helper = new BulkIndexingHelper(); |
|
62
|
|
|
$helper->bulkIndex($indexName, false, $climate); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
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