1
|
|
|
<?php |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Task; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2017 Timo Hund <[email protected]> |
8
|
|
|
* All rights reserved |
9
|
|
|
* |
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
11
|
|
|
* free software; you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* The GNU General Public License can be found at |
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
18
|
|
|
* |
19
|
|
|
* This script is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
25
|
|
|
***************************************************************/ |
26
|
|
|
|
27
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository; |
28
|
|
|
use ApacheSolrForTypo3\Solr\Site; |
29
|
|
|
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; |
30
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
31
|
|
|
use TYPO3\CMS\Scheduler\Task\AbstractTask; |
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Abstract scheduler task for solr scheduler tasks, contains the logic to |
35
|
|
|
* retrieve the site, avoids serialization of site, when scheduler task is saved. |
36
|
|
|
* |
37
|
|
|
* @package ApacheSolrForTypo3\Solr\Task |
38
|
|
|
*/ |
39
|
|
|
abstract class AbstractSolrTask extends AbstractTask { |
40
|
|
|
/** |
41
|
|
|
* The site this task is supposed to initialize the index queue for. |
42
|
|
|
* |
43
|
|
|
* @var Site |
44
|
|
|
*/ |
45
|
|
|
protected $site; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The rootPageId of the site that should be reIndexed |
49
|
|
|
* |
50
|
|
|
* @var integer |
51
|
|
|
*/ |
52
|
|
|
protected $rootPageId; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return int |
56
|
|
|
*/ |
57
|
|
|
public function getRootPageId() |
58
|
|
|
{ |
59
|
|
|
return $this->rootPageId; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param int $rootPageId |
64
|
|
|
*/ |
65
|
5 |
|
public function setRootPageId($rootPageId) |
66
|
|
|
{ |
67
|
5 |
|
$this->rootPageId = $rootPageId; |
68
|
5 |
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return Site |
72
|
|
|
*/ |
73
|
5 |
|
public function getSite() |
74
|
|
|
{ |
75
|
5 |
|
if (!is_null($this->site)) { |
76
|
4 |
|
return $this->site; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
try { |
80
|
|
|
/** @var $siteRepository SiteRepository */ |
81
|
5 |
|
$siteRepository = GeneralUtility::makeInstance(SiteRepository::class); |
82
|
5 |
|
$this->site = $siteRepository->getSiteByRootPageId($this->rootPageId); |
83
|
|
|
} catch (\InvalidArgumentException $e) { |
84
|
|
|
$logger = GeneralUtility::makeInstance(SolrLogManager::class, __CLASS__); |
|
|
|
|
85
|
|
|
$logger->log(SolrLogManager::ERROR, 'Scheduler task tried to get invalid site'); |
86
|
|
|
} |
87
|
|
|
|
88
|
5 |
|
return $this->site; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
|
|
public function __sleep() |
95
|
|
|
{ |
96
|
|
|
$properties = get_object_vars($this); |
97
|
|
|
// avoid serialization if the site object |
98
|
|
|
unset($properties['site']); |
99
|
|
|
return array_keys($properties); |
100
|
|
|
} |
101
|
|
|
} |
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