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: 191
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:typo3-cms-extension
Requires
- php: 7.4.*||8.0.*||8.1.*||8.2.*||8.3.*
- typo3/cms-core: ^10.4||^11.5||^12.4
Requires (Dev)
- friendsoftypo3/phpstan-typo3: ^0.9
- typo3/cms-backend: ^12.4
- typo3/cms-composer-installers: ^5.0
- typo3/cms-frontend: ^12.4
- typo3/cms-install: ^12.4
- typo3/cms-lowlevel: ^12.4
- typo3/cms-tstemplate: ^12.4
- typo3/coding-standards: ^0.5
- typo3/testing-framework: ^7.0
- vimeo/psalm: ^4.10
Suggests
- ext-yaml: *
This package is auto-updated.
Last update: 2024-10-26 16:05:22 UTC
README
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.