PHP Warning: Trying to access array offset on value of type null
Bug Report
Current Behavior Calling the cart leads to the exceptions:
PHP Warning: Trying to access array offset on value of type null in /var/website/current/html/typo3conf/ext/cart/Classes/Utility/ParserUtility.php line 68
and
PHP Warning: Trying to access array offset on value of type null in /var/website/current/html/typo3conf/ext/cart/Classes/Utility/ParserUtility.php line 134
Environment
- TYPO3 version(s): 11.5.7
- cart version: 8.2.0
- PHP: 8.1
- Is your TYPO3 installation set up with Composer (Composer Mode): yes
- OS: Debian
Possible Solution
change if ($pluginSettingsType['options']) { inside parseServices method to if (!empty($pluginSettingsType['options'])) {
and change if (is_array($pluginSettingsType[$selectedCountry])) { inside getTypePluginSettings method to if (!empty($pluginSettingsType[$selectedCountry]) && is_array($pluginSettingsType[$selectedCountry])) {
@extcode The first problem seems to be solved with https://github.com/extcode/cart/commit/1e6f491a2e1094a2ab45d7c1f2d3318e524da361
The second is not solved. But it makes me thinking. The second problem can only happen if you have a configuration like plugin.tx_cart.shippings.<country> or plugin.tx_cart.payments.<country>. Both are according to the documentation not correct. They were already correctly documented but the TypoScript itself was wrong and is now solved with https://github.com/extcode/cart/commit/ca21269f43c9cb77c48c466873a0728fdadc9eb3
That means imo that the following lines should be superfluous.
https://github.com/extcode/cart/blob/f09d45f816df849cc850478c37961b832c5c1b81/Classes/Utility/ParserUtility.php#L130-L134
So they can be removed (but need a changelog because they might be breaking for some installations which still use the old scheme!?)
Yes, it was previously possible to specify the configurations without .countries. Since this option has been removed from the documentation, it does not need to be supported.
Presumably there will be a major change here for TYPO3 v13. Services will then take over the loading of the configurations. In addition to the service for TypoScript, there will also be one for the Site Configuration Sets so that the new feature can be used. Corresponding interfaces will then allow you to make your own implementations of the service so that you can also obtain the data from other sources.
This was solved with #504