xperseguers / t3ext-cloudflare

The Cloudflare TYPO3 extension ensures your TYPO3 website is running optimally on the Cloudflare platform.
https://extensions.typo3.org/extension/cloudflare
GNU General Public License v3.0
7 stars 11 forks source link

[BUGFIX] Generate frontend url within backend compatible with all current TYPO3 version back to v7 #22

Closed tpinne closed 2 months ago

tpinne commented 3 years ago

This change is based on the usage of nng/nnhelpers package which provides various helper methods and fixes #21.

I tested it with TYPO3 v10.4.17 but the implementation suggests that it is compatible from v7 to v11 https://bitbucket.org/99grad/nnhelpers/src/a21c9811d7b47651b8b08d0247fb176ecb087524/Classes/Utilities/Tsfe.php#lines-93

tpinne commented 3 years ago

Maybe use the code of that extension as inspiration. I just noticed that it also introduces a domain model along with a new database table, which would be likely too much technical debt, for the purpose of the cloudflare extension. I'll go with it for now, because we need a quick solution to get our project onto TYPO3 v10.

tpinne commented 2 years ago

I don't say you should, but maybe use it as an inspiration for a custom implementation. The linked init method in that repo is completely based on vanilla TYPO3 classes/methods. And the version checks in that init method are also based on vanilla code https://bitbucket.org/99grad/nnhelpers/src/a21c9811d7b47651b8b08d0247fb176ecb087524/Classes/nnhelpers.php#lines-354

public static function t3Version() {
    return floor(VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)/1000000);
}

Currently I don't know how much more there is to do to generate absolute url in regards to support all TYPO3 versions. I used a method from another of their utility classes to generate the (absolute) page url https://bitbucket.org/99grad/nnhelpers/src/a21c9811d7b47651b8b08d0247fb176ecb087524/Classes/Utilities/Page.php#lines-201 . And the crucial point there is the following code I think.

$cObj = \nn\t3::injectClass( \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class );

The \nn\t3::injectClass https://bitbucket.org/99grad/nnhelpers/src/a21c9811d7b47651b8b08d0247fb176ecb087524/Classes/nnhelpers.php#lines-323 method ultimately uses the following:

$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
return $objectManager->get($class);

So this is what I meant as inspiration. If I have time in between projects I might try to refactor the code and take inspiration from them with giving credits.

But leaving the extension marked as fully compatible with TYPO3 >= 10 while it isn't, isn't an ideal solution either. So maybe try to adapt based on my suggestions, or wait until I find free time or mention in the docs that this particular function is not compatible for TYPO3 >= 10 or disable it based on TYPO3_version.

tpinne commented 2 years ago

I found a bit of time to pick the pieces together and created a helper class with no external dependencies. I currently could only test it with TYPO3 10.4.23. But that works. Hope you have the possibility to test it against other versions.

tpinne commented 2 years ago

Hi, is there any chance this might get merged?

xperseguers commented 2 months ago

Latest version fixes everything in that regards.