1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Site; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2017 - Thomas Hohn <[email protected]> |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver; |
29
|
|
|
use ApacheSolrForTypo3\Solr\FrontendEnvironment; |
30
|
|
|
use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache; |
31
|
|
|
use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration; |
32
|
|
|
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository; |
33
|
|
|
use ApacheSolrForTypo3\Solr\System\Records\SystemLanguage\SystemLanguageRepository; |
34
|
|
|
use ApacheSolrForTypo3\Solr\System\Service\SiteService; |
35
|
|
|
use ApacheSolrForTypo3\Solr\System\Util\SiteUtility; |
36
|
|
|
use ApacheSolrForTypo3\Solr\Util; |
37
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
38
|
|
|
use TYPO3\CMS\Core\Exception\SiteNotFoundException; |
39
|
|
|
use TYPO3\CMS\Core\Registry; |
40
|
|
|
use TYPO3\CMS\Core\Site\SiteFinder; |
41
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
42
|
|
|
use TYPO3\CMS\Core\Utility\RootlineUtility; |
43
|
|
|
use TYPO3\CMS\Frontend\Compatibility\LegacyDomainResolver; |
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* SiteRepository |
47
|
|
|
* |
48
|
|
|
* Responsible to retrieve instances of Site objects |
49
|
|
|
* |
50
|
|
|
* @author Thomas Hohn <[email protected]> |
51
|
|
|
*/ |
52
|
|
|
class SiteRepository |
53
|
|
|
{ |
54
|
|
|
/** |
55
|
|
|
* Rootpage resolver |
56
|
|
|
* |
57
|
|
|
* @var RootPageResolver |
58
|
|
|
*/ |
59
|
|
|
protected $rootPageResolver; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var TwoLevelCache |
63
|
|
|
*/ |
64
|
|
|
protected $runtimeCache; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var Registry |
68
|
|
|
*/ |
69
|
|
|
protected $registry; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var SiteFinder |
73
|
|
|
*/ |
74
|
|
|
protected $siteFinder; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var ExtensionConfiguration |
78
|
|
|
*/ |
79
|
|
|
protected $extensionConfiguration; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var FrontendEnvironment |
83
|
|
|
*/ |
84
|
|
|
protected $frontendEnvironment = null; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* SiteRepository constructor. |
88
|
|
|
* |
89
|
|
|
* @param RootPageResolver|null $rootPageResolver |
90
|
|
|
* @param TwoLevelCache|null $twoLevelCache |
91
|
|
|
* @param Registry|null $registry |
92
|
|
|
* @param SiteFinder|null $siteFinder |
93
|
|
|
* @param ExtensionConfiguration| null |
|
|
|
|
94
|
|
|
*/ |
95
|
195 |
|
public function __construct( |
96
|
|
|
RootPageResolver $rootPageResolver = null, |
97
|
|
|
TwoLevelCache $twoLevelCache = null, |
98
|
|
|
Registry $registry = null, |
99
|
|
|
SiteFinder $siteFinder = null, |
100
|
|
|
ExtensionConfiguration $extensionConfiguration = null, |
101
|
|
|
FrontendEnvironment $frontendEnvironment = null |
102
|
|
|
) |
103
|
|
|
{ |
104
|
195 |
|
$this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class); |
105
|
195 |
|
$this->runtimeCache = $twoLevelCache ?? GeneralUtility::makeInstance(TwoLevelCache::class, /** @scrutinizer ignore-type */'cache_runtime'); |
106
|
195 |
|
$this->registry = $registry ?? GeneralUtility::makeInstance(Registry::class); |
107
|
195 |
|
$this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class); |
108
|
195 |
|
$this->extensionConfiguration = $extensionConfiguration ?? GeneralUtility::makeInstance(ExtensionConfiguration::class); |
109
|
195 |
|
$this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class); |
110
|
195 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Gets the Site for a specific page Id. |
114
|
|
|
* |
115
|
|
|
* @param int $pageId The page Id to get a Site object for. |
116
|
|
|
* @param string $mountPointIdentifier |
117
|
|
|
* @return SiteInterface Site for the given page Id. |
118
|
|
|
*/ |
119
|
113 |
|
public function getSiteByPageId($pageId, $mountPointIdentifier = '') |
120
|
|
|
{ |
121
|
113 |
|
$rootPageId = $this->rootPageResolver->getRootPageId($pageId, false, $mountPointIdentifier); |
122
|
113 |
|
return $this->getSiteByRootPageId($rootPageId); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Gets the Site for a specific root page Id. |
127
|
|
|
* |
128
|
|
|
* @param int $rootPageId Root page Id to get a Site object for. |
129
|
|
|
* @return SiteInterface Site for the given page Id. |
130
|
|
|
*/ |
131
|
130 |
|
public function getSiteByRootPageId($rootPageId) |
132
|
|
|
{ |
133
|
130 |
|
$cacheId = 'SiteRepository' . '_' . 'getSiteByPageId' . '_' . $rootPageId; |
134
|
|
|
|
135
|
130 |
|
$methodResult = $this->runtimeCache->get($cacheId); |
136
|
130 |
|
if (!empty($methodResult)) { |
137
|
98 |
|
return $methodResult; |
138
|
|
|
} |
139
|
|
|
|
140
|
130 |
|
$methodResult = $this->buildSite($rootPageId); |
141
|
123 |
|
$this->runtimeCache->set($cacheId, $methodResult); |
142
|
|
|
|
143
|
123 |
|
return $methodResult; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Returns the first available Site. |
148
|
|
|
* |
149
|
|
|
* @param bool $stopOnInvalidSite |
150
|
|
|
* @throws \Exception |
151
|
|
|
* @return Site |
152
|
|
|
*/ |
153
|
21 |
|
public function getFirstAvailableSite($stopOnInvalidSite = false) |
154
|
|
|
{ |
155
|
21 |
|
$sites = $this->getAvailableSites($stopOnInvalidSite); |
156
|
21 |
|
return array_shift($sites); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Gets all available TYPO3 sites with Solr configured. |
161
|
|
|
* |
162
|
|
|
* @param bool $stopOnInvalidSite |
163
|
|
|
* @throws \Exception |
164
|
|
|
* @return Site[] An array of availablesites |
165
|
|
|
*/ |
166
|
79 |
|
public function getAvailableSites($stopOnInvalidSite = false) |
167
|
|
|
{ |
168
|
79 |
|
$cacheId = 'SiteRepository' . '_' . 'getAvailableSites'; |
169
|
|
|
|
170
|
79 |
|
$sites = $this->runtimeCache->get($cacheId); |
171
|
79 |
|
if (!empty($sites)) { |
172
|
13 |
|
return $sites; |
173
|
|
|
} |
174
|
|
|
|
175
|
79 |
|
if ($this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) { |
176
|
|
|
$sites = $this->getAvailableLegacySites($stopOnInvalidSite); |
|
|
|
|
177
|
|
|
} else { |
178
|
79 |
|
$sites = $this->getAvailableTYPO3ManagedSites($stopOnInvalidSite); |
179
|
|
|
} |
180
|
|
|
|
181
|
79 |
|
$this->runtimeCache->set($cacheId, $sites); |
182
|
|
|
|
183
|
79 |
|
return $sites; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @deprecated deprecated since EXT:solr 10 will be removed with EXT:solr 11 please use the site handling now |
188
|
|
|
* @param bool $stopOnInvalidSite |
189
|
|
|
* @return array |
190
|
|
|
*/ |
191
|
|
|
protected function getAvailableLegacySites(bool $stopOnInvalidSite): array |
192
|
|
|
{ |
193
|
|
|
$serversFromRegistry = $this->getSolrServersFromRegistry(); |
|
|
|
|
194
|
|
|
if(empty($serversFromRegistry)) { |
195
|
|
|
return []; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
trigger_error('solr:deprecation: Method getAvailableLegacySites is deprecated since EXT:solr 10 and will be removed in v11, please use the site handling to configure EXT:solr', E_USER_DEPRECATED); |
199
|
|
|
$legacySites = []; |
200
|
|
|
foreach ($serversFromRegistry as $server) { |
201
|
|
|
if (isset($legacySites[$server['rootPageUid']])) { |
202
|
|
|
//get each site only once |
203
|
|
|
continue; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
try { |
207
|
|
|
$legacySites[$server['rootPageUid']] = $this->buildSite($server['rootPageUid']); |
208
|
|
|
} catch (\InvalidArgumentException $e) { |
209
|
|
|
if ($stopOnInvalidSite) { |
210
|
|
|
throw $e; |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
return $legacySites; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @param bool $stopOnInvalidSite |
220
|
|
|
* @return array |
221
|
|
|
* @throws \Exception |
222
|
|
|
*/ |
223
|
79 |
|
protected function getAvailableTYPO3ManagedSites(bool $stopOnInvalidSite): array |
224
|
|
|
{ |
225
|
79 |
|
$typo3ManagedSolrSites = []; |
226
|
79 |
|
$typo3Sites = $this->siteFinder->getAllSites(); |
227
|
79 |
|
foreach ($typo3Sites as $typo3Site) { |
228
|
|
|
try { |
229
|
79 |
|
$rootPageId = $typo3Site->getRootPageId(); |
230
|
79 |
|
if (isset($typo3ManagedSolrSites[$rootPageId])) { |
231
|
|
|
//get each site only once |
232
|
|
|
continue; |
233
|
|
|
} |
234
|
|
|
|
235
|
79 |
|
$typo3ManagedSolrSites[$rootPageId] = $this->buildSite($rootPageId); |
236
|
|
|
|
237
|
68 |
|
} catch (\Exception $e) { |
238
|
68 |
|
if ($stopOnInvalidSite) { |
239
|
|
|
throw $e; |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
} |
243
|
79 |
|
return $typo3ManagedSolrSites; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Gets the system languages (IDs) for which Solr connections have been |
248
|
|
|
* configured. |
249
|
|
|
* |
250
|
|
|
* @param Site $site |
251
|
|
|
* @return array |
252
|
|
|
* @throws \ApacheSolrForTypo3\Solr\NoSolrConnectionFoundException |
253
|
|
|
* @deprecated use $site->getConnectionConfig |
254
|
|
|
*/ |
255
|
|
|
public function getAllLanguages(Site $site) |
256
|
|
|
{ |
257
|
|
|
trigger_error('solr:deprecation: Method getAllLanguages is deprecated since EXT:solr 10 and will be removed in v11, use $site->getConnectionConfig instead', E_USER_DEPRECATED); |
258
|
|
|
|
259
|
|
|
$siteLanguages = []; |
260
|
|
|
foreach ($site->getAllSolrConnectionConfigurations() as $solrConnectionConfiguration) { |
261
|
|
|
$siteLanguages[] = $solrConnectionConfiguration['language']; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
return $siteLanguages; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Creates an instance of the Site object. |
269
|
|
|
* |
270
|
|
|
* @param integer $rootPageId |
271
|
|
|
* @throws \InvalidArgumentException |
272
|
|
|
* @return SiteInterface |
273
|
|
|
*/ |
274
|
170 |
|
protected function buildSite($rootPageId) |
275
|
|
|
{ |
276
|
170 |
|
if (empty($rootPageId)) { |
277
|
|
|
throw new \InvalidArgumentException('Root page id can not be empty'); |
278
|
|
|
} |
279
|
170 |
|
$rootPageRecord = (array)BackendUtility::getRecord('pages', $rootPageId); |
280
|
|
|
|
281
|
170 |
|
$this->validateRootPageRecord($rootPageId, $rootPageRecord); |
282
|
|
|
|
283
|
|
|
//@todo The handling of the legacy site can be removed in EXT:solr 11 |
284
|
159 |
|
if (!SiteUtility::getIsSiteManagedSite($rootPageId) && $this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) { |
285
|
|
|
return $this->buildLegacySite($rootPageRecord); |
|
|
|
|
286
|
|
|
} |
287
|
|
|
|
288
|
159 |
|
return $this->buildTypo3ManagedSite($rootPageRecord); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Retrieves the default language by the rootPageId of a site. |
293
|
|
|
* |
294
|
|
|
* @param int $rootPageId |
295
|
|
|
* @return int|mixed |
296
|
|
|
* @deprecated Use Site directly |
297
|
|
|
*/ |
298
|
|
|
protected function getDefaultLanguage($rootPageId) |
299
|
|
|
{ |
300
|
|
|
trigger_error('solr:deprecation: Method getDefaultLanguage is deprecated since EXT:solr 10 and will be removed in v11, use the site directly instead', E_USER_DEPRECATED); |
301
|
|
|
|
302
|
|
|
$siteDefaultLanguage = 0; |
303
|
|
|
|
304
|
|
|
$configuration = $this->frontendEnvironment->getConfigurationFromPageId($rootPageId, 'config'); |
305
|
|
|
|
306
|
|
|
$siteDefaultLanguage = $configuration->getValueByPathOrDefaultValue('sys_language_uid', $siteDefaultLanguage); |
307
|
|
|
// default language is set through default L GET parameter -> overruling config.sys_language_uid |
308
|
|
|
$siteDefaultLanguage = $configuration->getValueByPathOrDefaultValue('defaultGetVars.L', $siteDefaultLanguage); |
309
|
|
|
|
310
|
|
|
return $siteDefaultLanguage; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* Retrieves the configured solr servers from the registry. |
315
|
|
|
* |
316
|
|
|
* @deprecated This method is only required for old solr based sites. |
317
|
|
|
* @return array |
318
|
|
|
*/ |
319
|
|
|
protected function getSolrServersFromRegistry() |
320
|
|
|
{ |
321
|
|
|
trigger_error('solr:deprecation: Method getSolrServersFromRegistry is deprecated since EXT:solr 10 and will be removed in v11, use sitehanlding instead', E_USER_DEPRECATED); |
322
|
|
|
|
323
|
|
|
$servers = (array)$this->registry->get('tx_solr', 'servers', []); |
324
|
|
|
return $servers; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* @param $rootPageId |
329
|
|
|
* @deprecated This method is only required for old solr based sites. |
330
|
|
|
* @return NULL|string |
331
|
|
|
*/ |
332
|
|
|
protected function getDomainFromConfigurationOrFallbackToDomainRecord($rootPageId) |
333
|
|
|
{ |
334
|
|
|
trigger_error('solr:deprecation: Method getDomainFromConfigurationOrFallbackToDomainRecord is deprecated since EXT:solr 10 and will be removed in v11, use sitehanlding instead', E_USER_DEPRECATED); |
335
|
|
|
|
336
|
|
|
/** @var $siteService SiteService */ |
337
|
|
|
$siteService = GeneralUtility::makeInstance(SiteService::class); |
338
|
|
|
$domain = $siteService->getFirstDomainForRootPage($rootPageId); |
339
|
|
|
if ($domain === '') { |
340
|
|
|
$rootlineUtility = GeneralUtility::makeInstance(RootlineUtility::class, $rootPageId); |
341
|
|
|
try { |
342
|
|
|
$rootLine = $rootlineUtility->get(); |
343
|
|
|
} catch (\RuntimeException $e) { |
344
|
|
|
$rootLine = []; |
345
|
|
|
} |
346
|
|
|
$domain = $this->firstDomainRecordFromLegacyDomainResolver($rootLine); |
347
|
|
|
return (string)$domain; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
return $domain; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* @param $rootLine |
355
|
|
|
* @return null|string |
356
|
|
|
*/ |
357
|
|
|
private function firstDomainRecordFromLegacyDomainResolver($rootLine) |
358
|
|
|
{ |
359
|
|
|
trigger_error('Method firstDomainRecordFromLegacyDomainResolver is deprecated since EXT:solr 10 and will be removed in v11, use sitehandling instead.', E_USER_DEPRECATED); |
360
|
|
|
$domainResolver = GeneralUtility::makeInstance(LegacyDomainResolver::class); |
361
|
|
|
foreach ($rootLine as $row) { |
362
|
|
|
$domain = $domainResolver->matchRootPageId($row['uid']); |
363
|
|
|
if (is_array($domain)) { |
364
|
|
|
return rtrim($domain['domainName'], '/'); |
365
|
|
|
} |
366
|
|
|
} |
367
|
|
|
return null; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* @param string $domain |
372
|
|
|
* @return string |
373
|
|
|
*/ |
374
|
159 |
|
protected function getSiteHashForDomain($domain) |
375
|
|
|
{ |
376
|
|
|
/** @var $siteHashService SiteHashService */ |
377
|
159 |
|
$siteHashService = GeneralUtility::makeInstance(SiteHashService::class); |
378
|
159 |
|
$siteHash = $siteHashService->getSiteHashForDomain($domain); |
379
|
159 |
|
return $siteHash; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @param int $rootPageId |
384
|
|
|
* @param array $rootPageRecord |
385
|
|
|
* @throws \InvalidArgumentException |
386
|
|
|
*/ |
387
|
170 |
|
protected function validateRootPageRecord($rootPageId, $rootPageRecord) |
388
|
|
|
{ |
389
|
170 |
|
if (empty($rootPageRecord)) { |
390
|
73 |
|
throw new \InvalidArgumentException( |
391
|
73 |
|
'The rootPageRecord for the given rootPageRecord ID \'' . $rootPageId . '\' could not be found in the database and can therefore not be used as site root rootPageRecord.', |
392
|
73 |
|
1487326416 |
393
|
|
|
); |
394
|
|
|
} |
395
|
|
|
|
396
|
160 |
|
if (!Site::isRootPage($rootPageRecord)) { |
397
|
3 |
|
throw new \InvalidArgumentException( |
398
|
3 |
|
'The rootPageRecord for the given rootPageRecord ID \'' . $rootPageId . '\' is not marked as root rootPageRecord and can therefore not be used as site root rootPageRecord.', |
399
|
3 |
|
1309272922 |
400
|
|
|
); |
401
|
|
|
} |
402
|
159 |
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* |
406
|
|
|
* @param array $rootPageRecord |
407
|
|
|
* @return LegacySite |
408
|
|
|
* @throws Exception\InvalidSiteConfigurationCombinationException |
409
|
|
|
* @deprecated buildLegacySite is deprecated and will be removed in EXT:solr 11. Please configure your system with the TYPO3 sitehandling |
410
|
|
|
*/ |
411
|
|
|
protected function buildLegacySite($rootPageRecord): LegacySite |
412
|
|
|
{ |
413
|
|
|
trigger_error('solr:deprecation: You are using EXT:solr without sitehandling. This setup is deprecated and will be removed in EXT:solr 11', E_USER_DEPRECATED); |
414
|
|
|
|
415
|
|
|
if (!$this->extensionConfiguration->getIsAllowLegacySiteModeEnabled()) { |
416
|
|
|
throw new Exception\InvalidSiteConfigurationCombinationException('It was tried to boot legacy site configuration, but allowLegacySiteMode is not enabled. ' . |
417
|
|
|
'Please use site handling feature or enable legacy mode under "Settings":>"Extension Configuration":>"solr"', 1567770263); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($rootPageRecord['uid']); |
421
|
|
|
$domain = $this->getDomainFromConfigurationOrFallbackToDomainRecord($rootPageRecord['uid']); |
|
|
|
|
422
|
|
|
$siteHash = $this->getSiteHashForDomain($domain); |
423
|
|
|
$defaultLanguage = $this->getDefaultLanguage($rootPageRecord['uid']); |
|
|
|
|
424
|
|
|
$pageRepository = GeneralUtility::makeInstance(PagesRepository::class); |
425
|
|
|
$availableLanguageIds = GeneralUtility::makeInstance(SystemLanguageRepository::class)->findSystemLanguages(); |
426
|
|
|
|
427
|
|
|
return GeneralUtility::makeInstance( |
428
|
|
|
LegacySite::class, |
429
|
|
|
/** @scrutinizer ignore-type */ |
430
|
|
|
$solrConfiguration, |
431
|
|
|
/** @scrutinizer ignore-type */ |
432
|
|
|
$rootPageRecord, |
433
|
|
|
/** @scrutinizer ignore-type */ |
434
|
|
|
$domain, |
435
|
|
|
/** @scrutinizer ignore-type */ |
436
|
|
|
$siteHash, |
437
|
|
|
/** @scrutinizer ignore-type */ |
438
|
|
|
$pageRepository, |
439
|
|
|
/** @scrutinizer ignore-type */ |
440
|
|
|
$defaultLanguage, |
441
|
|
|
/** @scrutinizer ignore-type */ |
442
|
|
|
$availableLanguageIds |
443
|
|
|
); |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* @param array $rootPageRecord |
448
|
|
|
* @return Typo3ManagedSite |
449
|
|
|
*/ |
450
|
159 |
|
protected function buildTypo3ManagedSite(array $rootPageRecord): ?Typo3ManagedSite |
451
|
|
|
{ |
452
|
159 |
|
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($rootPageRecord['uid']); |
453
|
|
|
/** @var \TYPO3\CMS\Core\Site\Entity\Site $typo3Site */ |
454
|
|
|
try { |
455
|
159 |
|
$typo3Site = $this->siteFinder->getSiteByPageId($rootPageRecord['uid']); |
456
|
|
|
} catch (SiteNotFoundException $e) { |
457
|
|
|
return null; |
458
|
|
|
} |
459
|
159 |
|
$domain = $typo3Site->getBase()->getHost(); |
460
|
|
|
|
461
|
159 |
|
$siteHash = $this->getSiteHashForDomain($domain); |
462
|
159 |
|
$defaultLanguage = $typo3Site->getDefaultLanguage()->getLanguageId(); |
463
|
159 |
|
$pageRepository = GeneralUtility::makeInstance(PagesRepository::class); |
464
|
|
|
$availableLanguageIds = array_map(function($language) { |
465
|
159 |
|
return $language->getLanguageId(); |
466
|
159 |
|
}, $typo3Site->getLanguages()); |
467
|
|
|
|
468
|
159 |
|
$solrConnectionConfigurations = []; |
469
|
|
|
|
470
|
159 |
|
foreach ($availableLanguageIds as $languageUid) { |
471
|
159 |
|
$solrEnabled = SiteUtility::getConnectionProperty($typo3Site, 'enabled', $languageUid, 'read', true); |
|
|
|
|
472
|
159 |
|
if ($solrEnabled) { |
473
|
159 |
|
$solrConnectionConfigurations[$languageUid] = [ |
474
|
159 |
|
'connectionKey' => $rootPageRecord['uid'] . '|' . $languageUid, |
475
|
159 |
|
'rootPageTitle' => $rootPageRecord['title'], |
476
|
159 |
|
'rootPageUid' => $rootPageRecord['uid'], |
477
|
|
|
'read' => [ |
478
|
159 |
|
'scheme' => SiteUtility::getConnectionProperty($typo3Site, 'scheme', $languageUid, 'read', 'http'), |
479
|
159 |
|
'host' => SiteUtility::getConnectionProperty($typo3Site, 'host', $languageUid, 'read', 'localhost'), |
480
|
159 |
|
'port' => (int)SiteUtility::getConnectionProperty($typo3Site, 'port', $languageUid, 'read', 8983), |
481
|
|
|
// @todo: transform core to path |
482
|
|
|
'path' => |
483
|
159 |
|
SiteUtility::getConnectionProperty($typo3Site, 'path', $languageUid, 'read', '/solr/') . |
484
|
159 |
|
SiteUtility::getConnectionProperty($typo3Site, 'core', $languageUid, 'read', 'core_en') . '/' , |
485
|
159 |
|
'username' => SiteUtility::getConnectionProperty($typo3Site, 'username', $languageUid, 'read', ''), |
486
|
159 |
|
'password' => SiteUtility::getConnectionProperty($typo3Site, 'password', $languageUid, 'read', ''), |
487
|
159 |
|
'timeout' => SiteUtility::getConnectionProperty($typo3Site, 'timeout', $languageUid, 'read', 0) |
488
|
|
|
], |
489
|
|
|
'write' => [ |
490
|
159 |
|
'scheme' => SiteUtility::getConnectionProperty($typo3Site, 'scheme', $languageUid, 'write', 'http'), |
491
|
159 |
|
'host' => SiteUtility::getConnectionProperty($typo3Site, 'host', $languageUid, 'write', 'localhost'), |
492
|
159 |
|
'port' => (int)SiteUtility::getConnectionProperty($typo3Site, 'port', $languageUid, 'write', 8983), |
493
|
|
|
// @todo: transform core to path |
494
|
|
|
'path' => |
495
|
159 |
|
SiteUtility::getConnectionProperty($typo3Site, 'path', $languageUid, 'read', '/solr/') . |
496
|
159 |
|
SiteUtility::getConnectionProperty($typo3Site, 'core', $languageUid, 'read', 'core_en') . '/' , |
497
|
159 |
|
'username' => SiteUtility::getConnectionProperty($typo3Site, 'username', $languageUid, 'write', ''), |
498
|
159 |
|
'password' => SiteUtility::getConnectionProperty($typo3Site, 'password', $languageUid, 'write', ''), |
499
|
159 |
|
'timeout' => SiteUtility::getConnectionProperty($typo3Site, 'timeout', $languageUid, 'write', 0) |
500
|
|
|
], |
501
|
|
|
|
502
|
159 |
|
'language' => $languageUid |
503
|
|
|
]; |
504
|
|
|
} |
505
|
|
|
} |
506
|
|
|
|
507
|
159 |
|
return GeneralUtility::makeInstance( |
508
|
159 |
|
Typo3ManagedSite::class, |
509
|
|
|
/** @scrutinizer ignore-type */ |
510
|
159 |
|
$solrConfiguration, |
511
|
|
|
/** @scrutinizer ignore-type */ |
512
|
159 |
|
$rootPageRecord, |
513
|
|
|
/** @scrutinizer ignore-type */ |
514
|
159 |
|
$domain, |
515
|
|
|
/** @scrutinizer ignore-type */ |
516
|
159 |
|
$siteHash, |
517
|
|
|
/** @scrutinizer ignore-type */ |
518
|
159 |
|
$pageRepository, |
519
|
|
|
/** @scrutinizer ignore-type */ |
520
|
159 |
|
$defaultLanguage, |
521
|
|
|
/** @scrutinizer ignore-type */ |
522
|
159 |
|
$availableLanguageIds, |
523
|
|
|
/** @scrutinizer ignore-type */ |
524
|
159 |
|
$solrConnectionConfigurations, |
525
|
|
|
/** @scrutinizer ignore-type */ |
526
|
159 |
|
$typo3Site |
527
|
|
|
); |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
} |
531
|
|
|
|
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