Total Complexity | 15 |
Total Lines | 147 |
Duplicated Lines | 0 % |
Coverage | 53.23% |
Changes | 0 |
1 | <?php |
||
41 | class IndexAdministrationModuleController extends AbstractModuleController |
||
|
|||
42 | { |
||
43 | |||
44 | /** |
||
45 | * @var Queue |
||
46 | */ |
||
47 | protected $indexQueue; |
||
48 | |||
49 | /** |
||
50 | * @var ConnectionManager |
||
51 | */ |
||
52 | protected $solrConnectionManager; |
||
53 | |||
54 | /** |
||
55 | * @param ConnectionManager $solrConnectionManager |
||
56 | */ |
||
57 | public function setSolrConnectionManager(ConnectionManager $solrConnectionManager) |
||
60 | 3 | } |
|
61 | 3 | ||
62 | /** |
||
63 | * Initializes the controller before invoking an action method. |
||
64 | */ |
||
65 | protected function initializeAction() |
||
66 | { |
||
67 | parent::initializeAction(); |
||
68 | $this->indexQueue = GeneralUtility::makeInstance(Queue::class); |
||
69 | $this->solrConnectionManager = GeneralUtility::makeInstance(ConnectionManager::class); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Index action, shows an overview of available index maintenance operations. |
||
74 | */ |
||
75 | public function indexAction() |
||
76 | { |
||
77 | if ($this->selectedSite === null || empty($this->solrConnectionManager->getConnectionsBySite($this->selectedSite))) { |
||
78 | $this->view->assign('can_not_proceed', true); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Empties the site's indexes. |
||
84 | */ |
||
85 | public function emptyIndexAction() |
||
86 | { |
||
87 | $siteHash = $this->selectedSite->getSiteHash(); |
||
88 | |||
89 | try { |
||
90 | 1 | $affectedCores = []; |
|
91 | $solrServers = $this->solrConnectionManager->getConnectionsBySite($this->selectedSite); |
||
92 | 1 | foreach ($solrServers as $solrServer) { |
|
93 | $writeService = $solrServer->getWriteService(); |
||
94 | /* @var $solrServer SolrConnection */ |
||
95 | 1 | $writeService->deleteByQuery('siteHash:' . $siteHash); |
|
96 | 1 | $writeService->commit(false, false, false); |
|
97 | 1 | $affectedCores[] = $writeService->getPrimaryEndpoint()->getCore(); |
|
98 | 1 | } |
|
99 | $message = LocalizationUtility::translate('solr.backend.index_administration.index_emptied_all', 'Solr', [$this->selectedSite->getLabel(), implode(', ', $affectedCores)]); |
||
100 | 1 | $this->addFlashMessage($message); |
|
101 | 1 | } catch (\Exception $e) { |
|
102 | 1 | $this->addFlashMessage(LocalizationUtility::translate('solr.backend.index_administration.error.on_empty_index', 'Solr', [$e->__toString()]), '', FlashMessage::ERROR); |
|
103 | } |
||
104 | 1 | ||
105 | 1 | $this->redirect('index'); |
|
106 | } |
||
107 | |||
108 | /** |
||
109 | * Empties the Index Queue |
||
110 | 1 | */ |
|
111 | 1 | public function clearIndexQueueAction() |
|
112 | { |
||
113 | $this->indexQueue->deleteItemsBySite($this->selectedSite); |
||
114 | $this->addFlashMessage( |
||
115 | LocalizationUtility::translate( |
||
116 | 'solr.backend.index_administration.success.queue_emptied', |
||
117 | 'Solr', |
||
118 | [$this->selectedSite->getLabel()] |
||
119 | ) |
||
120 | ); |
||
121 | $this->redirectToReferrerModule(); |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Reloads the site's Solr cores. |
||
126 | */ |
||
127 | public function reloadIndexConfigurationAction() |
||
128 | { |
||
129 | $coresReloaded = true; |
||
130 | $reloadedCores = []; |
||
131 | $solrServers = $this->solrConnectionManager->getConnectionsBySite($this->selectedSite); |
||
132 | |||
133 | 2 | foreach ($solrServers as $solrServer) { |
|
134 | /* @var $solrServer SolrConnection */ |
||
135 | 2 | $coreAdmin = $solrServer->getAdminService(); |
|
136 | 2 | $coreReloaded = $coreAdmin->reloadCore()->getHttpStatus() === 200; |
|
137 | 2 | ||
138 | $coreName = $coreAdmin->getPrimaryEndpoint()->getCore(); |
||
139 | 2 | if (!$coreReloaded) { |
|
140 | $coresReloaded = false; |
||
141 | 2 | ||
142 | 2 | $this->addFlashMessage( |
|
143 | 'Failed to reload index configuration for core "' . $coreName . '"', |
||
144 | 2 | '', |
|
145 | 2 | FlashMessage::ERROR |
|
146 | ); |
||
147 | break; |
||
148 | } |
||
149 | |||
150 | $reloadedCores[] = $coreName; |
||
151 | } |
||
152 | |||
153 | if ($coresReloaded) { |
||
154 | $this->addFlashMessage( |
||
155 | 'Core configuration reloaded (' . implode(', ', $reloadedCores) . ').', |
||
156 | 2 | '', |
|
157 | FlashMessage::OK |
||
158 | ); |
||
159 | 2 | } |
|
160 | 2 | ||
161 | 2 | $this->redirect('index'); |
|
162 | 2 | } |
|
163 | 2 | ||
164 | /** |
||
165 | * Redirects to the referrer module index Action. |
||
166 | * |
||
167 | 2 | * Fluids <f:form VH can not make urls to other modules properly. |
|
168 | 2 | * The module name/key is not provided in the hidden fields __referrer by bulding form. |
|
169 | * So this is currently the single way to make it possible. |
||
170 | * |
||
171 | * @todo: remove this method if f:form works properly between backend modules. |
||
172 | */ |
||
173 | protected function redirectToReferrerModule() |
||
188 | } |
||
189 | } |
||
190 |
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