Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] PHP 8: Warning in ext_getSetup aborts indexing #3359

Closed
saitho opened this issue Oct 17, 2022 · 0 comments · Fixed by #3360
Closed

[BUG] PHP 8: Warning in ext_getSetup aborts indexing #3359

saitho opened this issue Oct 17, 2022 · 0 comments · Fixed by #3360

Comments

@saitho
Copy link
Contributor

saitho commented Oct 17, 2022

Describe the bug
Fetching nested TypoScript setup via ApacheSolrForTypo3\Solr\FrontendEnvironment\TypoScript::ext_getSetup(array $theSetup, string $theKey) results the following warning during indexing via backend:

TYPO3\CMS\Core\Error\Exception: Warning: Undefined array key "tx_myextension" in /var/www/html/public/typo3conf/ext/solr/Classes/FrontendEnvironment/TypoScript.php line 129 in /var/www/html/vendor/helhum/typo3-console/Classes/Console/Error/ErrorHandler.php:88
Stack trace:
#0 /var/www/html/public/typo3conf/ext/solr/Classes/FrontendEnvironment/TypoScript.php(129): Helhum\Typo3Console\Error\ErrorHandler->handleError(2, 'Undefined array...', '/var/www/html/p...', 129)
#1 /var/www/html/public/typo3conf/ext/solr/Classes/FrontendEnvironment/TypoScript.php(127): ApacheSolrForTypo3\Solr\FrontendEnvironment\TypoScript->ext_getSetup(Array, 'tx_myextension')
#2 /var/www/html/public/typo3conf/ext/solr/Classes/FrontendEnvironment/TypoScript.php(113): ApacheSolrForTypo3\Solr\FrontendEnvironment\TypoScript->ext_getSetup(Array, 'plugin.tx_myext...')
#3 /var/www/html/public/typo3conf/ext/solr/Classes/FrontendEnvironment/TypoScript.php(85): ApacheSolrForTypo3\Solr\FrontendEnvironment\TypoScript->buildConfigurationArray(1, 'plugin.tx_myext...', 0)
#4 /var/www/html/public/typo3conf/ext/solr/Classes/FrontendEnvironment.php(52): ApacheSolrForTypo3\Solr\FrontendEnvironment\TypoScript->getConfigurationFromPageId(1, 'plugin.tx_myext...', 0, NULL)
#5 /var/www/html/public/typo3conf/ext/tx_myextension/Classes/Helper/SolrHelper.php(253): ApacheSolrForTypo3\Solr\FrontendEnvironment->getConfigurationFromPageId(1, 'plugin.tx_myext...', 0)

This warning then results in an error during indexing.

To Reproduce

TypoScript setup:

plugin.tx_myextension {
  settings {
    foo = bar
  }
}

Snipped, placed inside a Solr indexer or Solr indexer hook:

use ApacheSolrForTypo3\Solr\FrontendEnvironment;

// @var $indexItem \ApacheSolrForTypo3\Solr\IndexQueue\Item

$settings =  GeneralUtility::makeInstance(FrontendEnvironment::class)
  ->getConfigurationFromPageId($indexItem->getRootPageUid(), 'plugin.tx_myextension', 0);
$config = $settings->getObjectByPathOrDefault('settings', []);
// $config should return the array ['foo' => 'bar']

Expected behavior

Missing value assignments to TypoScript structures should be ignored, defaulting to an empty string
as the original method of TYPO3 v11 does:
https://github.com/TYPO3/typo3/blob/11.5/typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php#L304

Used versions (please complete the following information):

  • TYPO3 Version: 11.5.16
  • EXT:solr Version: 11.5.0
  • PHP Version: 8.1.8
dkd-kaehm pushed a commit that referenced this issue Oct 18, 2022
Reading nested TypoScript will no longer log a warning when the
value can not be accessed. In this case, the second value in the
array returned in `TypoScript::ext_getSetup` will be an empty string.
However, the second value is not used by Ext:solr anymore.

This also fixes an issue with PHP 8 where such warning would cause the
indexing to fail, when the method is used inside of an indexer.

Fixes: #3359
dkd-kaehm pushed a commit that referenced this issue Oct 18, 2022
Reading nested TypoScript will no longer log a warning when the
value can not be accessed. In this case, the second value in the
array returned in `TypoScript::ext_getSetup` will be an empty string.
However, the second value is not used by Ext:solr anymore.

This also fixes an issue with PHP 8 where such warning would cause the
indexing to fail, when the method is used inside of an indexer.

Fixes: #3359
Ports: #3360
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant