Commit 4c17f442 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #12588 fix typo3 bootstrap for api.

parent 3d899071
Pipeline #5398 failed with stages
in 3 minutes and 39 seconds
......@@ -109,23 +109,41 @@ class T3Handler {
if (!self::isTypo3Loaded()) {
if (file_exists(Path::absoluteApp('vendor/autoload.php'))) {
// Typo3 version >=9
require Path::absoluteApp('vendor/autoload.php');
// Typo3 new installation since version >=9
$classLoader = require Path::absoluteApp('vendor/autoload.php');
} else {
// Typo3 version <=8
require Path::absoluteApp('typo3_src/vendor/autoload.php');
// Typo3 version <=8 or upgraded >=9
$classLoader = require Path::absoluteApp('typo3_src/vendor/autoload.php');
}
// run typo3 bootstrap if not yet happened. Necessary if run in unittest.
if (!defined('TYPO3_MODE')) {
// NOTE: Deprecated: Deprecation: #85821 - bootstrap methods
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
->setRequestType(TYPO3_REQUESTTYPE_AJAX)
->baseSetup(0);
// Alternate error fix if you don't want to run Typo3 bootstrap:
// error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
define('TYPO3_MODE', 'FE');
try {
// NOTE: Deprecated: Deprecation: #85821 - bootstrap methods
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
->setRequestType(TYPO3_REQUESTTYPE_AJAX)
->baseSetup(0);
} catch (\Throwable $e) {
try {
// The new way to bootstrap Typo3
// Documentation: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Bootstrapping/Index.html
// Typo3 testing framework example bootstrap: https://github.com/TYPO3/testing-framework/blob/9e8e2700bef2281af5d0b8d0693dd0b0cc1bfe04/Classes/Core/Functional/Framework/Frontend/RequestBootstrap.php
\TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run(0, \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_FE);
// The following line might be necessary but it aborts the execution without catchable error:
// \TYPO3\CMS\Core\Core\Bootstrap::init($classLoader)->get(\TYPO3\CMS\Frontend\Http\Application::class)->run();
} catch (\Throwable $e) {
Thrower::userFormException('Manual Typo3 bootstrap failed.');
}
}
// Alternate error fix if you don't want to run Typo3 bootstrap:
// error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
if (!defined('TYPO3_MODE')) {
define('TYPO3_MODE', 'FE');
}
}
}
}
......@@ -181,13 +199,19 @@ class T3Handler {
}
/**
* Note: Loads Typo3 if not running.
*
* @return string
*/
public static function getTypo3Version() {
public static function getTypo3Version()
{
self::t3AutoloadIfNotRunning();
return \TYPO3\CMS\Core\Utility\VersionNumberUtility::getNumericTypo3Version();
}
/**
* Note: Loads Typo3 if not running.
*
* @return bool
*/
public static function typo3VersionGreaterEqual10() {
......@@ -195,12 +219,24 @@ class T3Handler {
}
/**
* Note: Loads Typo3 if not running.
*
* @return bool
*/
public static function typo3VersionGreaterEqual9() {
return version_compare(self::getTypo3Version(), '9.0.0') >= 0;
}
/**
* Alias for typo3VersionGreaterEqual9()
* Introduced in case we want to change the version number at which slugs are mandatory.
*
* @return bool
*/
public static function useSlugsInsteadOfPageAlias() {
return self::typo3VersionGreaterEqual9();
}
/**
* Returns true if Typo3 classes are available.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment