Bug #87125
closedFrontendGroupRestriction class explode-Error in constructor
0%
Description
In several of my typo3 websites I have now experienced the same error while upgrading from v7.6 to v8.6.
In the Class /typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGroupRestriction in the constructor the line:
$this->frontendGroupIds = $frontendGroupIds === null ? explode(',', $GLOBALS['TSFE']->gr_list) : $frontendGroupIds;
throws an error on the explode command when executed from the TYPO3 BE.
This Bug has been reported before (https://forge.typo3.org/issues/79354, https://forge.typo3.org/issues/80917), but has not been resolved.
The error only happens in the TYPO3 BE, caused by different tasks (e.g. by the solr extension creating the queue or by other 3rd party extensions)
Would it be possible to add a $GLOBALS['TSFE'] check or a "if (TYPO3_MODE == 'FE')" check (as suggested in the related issues), before executing the explode command?
Updated by cosmoblonde GmbH almost 6 years ago
- Related to Bug #79354: PageRepository::getPage fails in Backend context added
Updated by Georg Ringer almost 6 years ago
- Related to Bug #80917: Backend: Uncaught TYPO3 Exception in FrontendGroupRestriction constructor if $GLOBALS['TSFE']->gr_list is null added
Updated by Georg Ringer almost 6 years ago
- Status changed from New to Needs Feedback
can you link the code where this is used in solr? why is the TSFE not fully initialized?
Updated by cosmoblonde GmbH almost 6 years ago
To be more precise, the problem appears when using solrfal. When a file is added to the index queue either by the planner task or when editing a record (e.g. news) that has files attached.
This is the error message:
Uncaught TYPO3 Exception
explode() expects parameter 2 to be string, null given
TypeError thrown in file
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGroupRestriction.php in line 37.
24 explode(",", NULL)
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGroupRestriction.php:
00035: {
00036: // if (TYPO3_MODE 'FE'){
00037: $this->frontendGroupIds = $frontendGroupIds = null ? explode(',', $GLOBALS['TSFE']->gr_list) : $frontendGroupIds;
00038: // }else{
00039: // $this->frontendGroupIds = array();
23 TYPO3\CMS\Core\Database\Query\Restriction\FrontendGroupRestriction::__construct()
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
03961: }
03962: // Create new instance and call constructor with parameters
03963: $instance = new $finalClassName(...$constructorArguments);
03964: // Register new singleton instance
03965: if ($instance instanceof SingletonInterface) {
22 TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("TYPO3\CMS\Core\Database\Query\Restriction\FrontendGroupRestriction")
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/core/Classes/Database/Query/Restriction/AbstractRestrictionContainer.php:
00099: protected function createRestriction($restrictionClass)
00100: {
00101: return GeneralUtility::makeInstance($restrictionClass);
00102: }
00103: }
21 TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer::createRestriction("TYPO3\CMS\Core\Database\Query\Restriction\FrontendGroupRestriction")
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendRestrictionContainer.php:
00045: {
00046: foreach ($this->defaultRestrictionTypes as $restrictionType) {
00047: $this->add($this->createRestriction($restrictionType));
00048: }
00049: }
20 TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer::__construct()
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
03961: }
03962: // Create new instance and call constructor with parameters
03963: $instance = new $finalClassName(...$constructorArguments);
03964: // Register new singleton instance
03965: if ($instance instanceof SingletonInterface) {
19 TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance("TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer")
/html/typo3/site_v8/shared/vendor/typo3_src-8.7.21/typo3/sysext/frontend/Classes/Page/PageRepository.php:
00562: >getQueryBuilderForTable($table);>setRestrictions(
00563: $queryBuilder
00564: GeneralUtility::makeInstance(FrontendRestrictionContainer::class)
00565: );
00566: $olrow = $queryBuilder->select('*')
18 TYPO3\CMS\Frontend\Page\PageRepository::getRecordOverlay("tx_news_domain_model_news", array, 1, "hideNonTranslated")
/html/typo3/site_v8/releases/initial/typo3conf/ext/solrfal/Classes/Detection/RecordContextDetector.php:
00154: $record,
00155: (int)$language,
00156: 'hideNonTranslated'
00157: );
00158: if ($translation) {
17 ApacheSolrForTypo3\Solrfal\Detection\RecordContextDetector::extractQueueItemsFromRecord("news", "tx_news_domain_model_news", array, array)
/html/typo3/site_v8/releases/initial/typo3conf/ext/solrfal/Classes/Detection/RecordContextDetector.php:
00298: $table,
00299: $record,
00300: $this->getFieldsToIndex($indexingConfiguration, $table)
00301: );
00302: } else {
16 ApacheSolrForTypo3\Solrfal\Detection\RecordContextDetector::recordCreated("tx_news_domain_model_news", 1493)
/html/typo3/site_v8/releases/initial/typo3conf/ext/solrfal/Classes/Detection/RecordContextDetector.php:
00321: }
00322:
00323: $this->recordCreated($table, $uid);
00324: }
00325:
15 ApacheSolrForTypo3\Solrfal\Detection\RecordContextDetector::recordUpdated("tx_news_domain_model_news", 1493)
/html/typo3/site_v8/releases/initial/typo3conf/ext/solrfal/Classes/Queue/ConsistencyAspect.php:
00182: $detectors = $this->getDetectorsForRecord($table, $uid);
00183: foreach ($detectors as $detector) {
00184: $detector->$function($table, $uid);
00185: }
00186: }
14 ApacheSolrForTypo3\Solrfal\Queue\ConsistencyAspect::issueCommandOnDetectors("recordUpdated", "sys_file_reference", 2644)
/html/typo3/site_v8/releases/initial/typo3conf/ext/solrfal/Classes/Queue/ConsistencyAspect.php:
00168: }
00169: if ($method !== '') {
00170: $this->issueCommandOnDetectors($method, $table, $id);
00171: }
00172: }
--------------------cut-------------------------------
But as mentioned before, I had the same error in a custom extension (indexing to ElasticSearch).
Updated by Georg Ringer almost 6 years ago
but how does the code look like to buil the tsfe? why it is not set there?
Updated by cosmoblonde GmbH almost 6 years ago
There is no code that builds/initializes the TSFE (possibly because it is called form the backend) and as it is a 3rd party extension, I would like to not make any changes here.
Is it not possible to just add a null check in the FrontendGroupRestriction class?
Updated by Georg Ringer almost 6 years ago
- Status changed from Needs Feedback to Rejected
in the FE TSFE is full initialized. The check won't be added as this would be just wrong. it TSFE is built incomplete by a 3rd party extension, it must be fixed there instead of in the core.
Timo Hund said it is no problem in EXT:solr as he remembers that EXT:solr has been changed in that regard.