Commit 3ea257fc authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Fix BackendUserAuth object for the VisibilitySettingsMigrationWizard

parent 47960d6a
......@@ -2,9 +2,14 @@
namespace TYPO3\Languagevisibility\Updates;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
......@@ -75,7 +80,7 @@ class VisibilitySettingsMigrationWizard implements UpgradeWizardInterface {
* @return bool
*/
public function executeUpdate(): bool {
$this->initializeBackendUserAuthentication();
$this->visibilityFlagRepository = GeneralUtility::makeInstance(VisibilityFlagRepository::class);
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
......@@ -425,4 +430,29 @@ class VisibilitySettingsMigrationWizard implements UpgradeWizardInterface {
DatabaseUpdatedPrerequisite::class
];
}
/**
* Initialize a BackendUserAuthentication if none exists
*/
protected function initializeBackendUserAuthentication(): void {
if (!$GLOBALS['BE_USER'] instanceof BackendUserAuthentication) {
if (Environment::isCli()) {
$GLOBALS['BE_USER'] = GeneralUtility::makeInstance(CommandLineUserAuthentication::class);
} else {
$GLOBALS['BE_USER'] = GeneralUtility::makeInstance(BackendUserAuthentication::class);
$GLOBALS['BE_USER']->start();
}
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '10.0.0', '<')) {
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
if (isset($GLOBALS['BE_USER']->uc['lang'])) {
$GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
} else {
$GLOBALS['LANG']->init('default');
}
} else {
$GLOBALS['LANG'] = LanguageService::createFromUserPreferences($GLOBALS['BE_USER']);
}
}
}
}
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