code711/speedupyaml

This extension provides an XCLASS for TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader to use the pecl extension YAML if available instead of the Symfonies\'s Yaml::parse. This extension is experimental and a proof-of-concept. It might work in production.

Installs: 237

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

dev-main 2024-06-26 15:19 UTC

This package is auto-updated.

Last update: 2024-12-26 16:26:09 UTC


README

Latest Stable Version TYPO3 12 TYPO3 11 TYPO3 10 Total Downloads Monthly Downloads

This extension is a proof of concept but should work in production as well.

TYPO3 uses the Symfony Yaml Component to parse YAML files. This is especially done in the TYPO3 Core class TYPO3\Core\Configuration\Loader\YamlFileLoader using the Symfony Yaml::parse method.

Me - and others - were under the impression that Yaml::parse will fall back to the PECL Yaml Extension using yaml_parse if available.

This is not the case, and seemingly never has been

This extension will XCLASS the TYPO3 core class TYPO3\\Core\\Configuration\\Loader\\YamlFileLoader and extend the method TYPO3\\Core\\Configuration\\Loader\\YamlFileLoader::loadAndParse so it will use the PECL yaml extension.

The PECL yaml extension will then use the official YAML parser written in C, making the parsing of YAML files about 40% faster.

Problems(?) / Limitations

The feature set of the PECL yaml extensions is different from the Symfony YAML Component, which does not cover the whole feature set of YAML, while the PECL extension does. This COULD lead to different results when parsing the same file.

Additionally, the Symfony Yaml Component might handle edge-cases differently than the PECL extension. I don't have enough examples what that might be, but in my TYPO3 centric tests everything resulted in the same parsed array.

This XCLASS will do nothing for EXT:forms. Helmut Hummels helhum/typo3-config-handling does something similar, but only for the scope of the extension. I actually took my inspiration for handling the error-cases yaml_parse might throw from this extension as an example.

I will not publish this extension to the TER for now, as this is something that should be handled in the core itself.

It should work on TYPO3 10, 11 and 12 as the TYPO3\\Core\\Configuration\\Loader\\YamlFileLoader class did not change in the regards that matter for the case here over that time.