brotkrueml / schema

TYPO3 extension providing an API and view helpers for schema.org markup
https://extensions.typo3.org/extension/schema
GNU General Public License v2.0
32 stars 9 forks source link

Uncaught TYPO3 Exception: syntax error, unexpected '=' | ParseError #92

Closed maslme closed 2 years ago

maslme commented 2 years ago

Current behavior

EXT: schema throws several Errors in the TYPO3 Log caused by the EXT:schema/ext_localconf.php lines 11 - 15.

Expected behavior/output

no error

Steps to reproduce

A clear step-by-step guide on how to reproduce the problem. Without this, it will be hard to help you further.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

Possible Solution

replace line11 - 15 in EXT:schema/ext_localconf.php with if(!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_IDENTIFIER])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_IDENTIFIER] ??= []; } if(!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER] ??= []; } if(!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER]['frontend'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER]['frontend'] ??= TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class; } if(!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER]['backend'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER]['backend'] ??= TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class; } if(!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER]['options'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][Brotkrueml\Schema\Extension::CACHE_CORE_IDENTIFIER]['options'] ??= ['defaultLifetime' => 0]; }

brotkrueml commented 2 years ago

@maslme Hmm, that doesn't make sense, as the null coalescing assignment operator makes exactly this, checking if the array key exists, and if not, assign the right side to the left side.

So, first, some questions:

brotkrueml commented 2 years ago

Closed due to lack of feedback. If you can contribute more information, reopen it or create a new topic.

maslme commented 2 years ago

Sorry, didn't get an notification that you need more informations. Here they are

@maslme Hmm, that doesn't make sense, as the null coalescing assignment operator makes exactly this, checking if the array key exists, and if not, assign the right side to the left side.

So, first, some questions:

  • When does the errors occur? I only saw the errors in the TYPO3 logfile

  • Please add more information for the error, like stack trace. As mentioned I have only the occurance in the error logfile.

  • Do you have a custom cache configuration for this extension? no

  • What is displayed in the module "System > Configuration > Global Configuration" for the EXT:schema caches? (SYS > caching > cacheConfigurations > tx_schema and tx_schema_core)? Sorry, don't know what you want to know.

  • Do you really use PHP 7.4? The error in the subject shows that the = from ??= is maybe not valid. Yes 7.4.29.

Perhaps you will have a look at https://github.com/a-r-m-i-n/min/issues/9 - there was the same issue in another extension.

brotkrueml commented 2 years ago

@maslme Nope, the null coalescing assignment operator was introduced with PHP 7.4: https://wiki.php.net/rfc/null_coalesce_equal_operator https://github.com/php/php-src/commit/a50198d0fef652ca052cda642d6e98a9101eb73f

Have a look here: PHP 7.4.29: https://3v4l.org/Cr3tZ#v7.4.29 (works as expected) PHP 7.3.33: https://3v4l.org/Cr3tZ#v7.3.33 (throws the mentioned error)

Also, it works with installations I am using (including PHP 7.4), the schema version 2 (which uses this syntax) was released many months ago and no one complained so far 'til now. So, there must be some difference that the error is thrown in your installation. Which distribution do you use? Do you use PHP from the distribution or from some 3rd party? What are your settings for error reportings on PHP level?

I would like to reproduce the problem before providing a patch. There must be a reason why this does not work for you but for all others.

For module "System > Configuration" you have to install the lowlevel system extension.

brotkrueml commented 2 years ago

Looks like the CLI was running on PHP 7.3, whereas the website runs on PHP 7.4.