Skip to content

Commit

Permalink
[BUGFIX] Create default site configuration on installation
Browse files Browse the repository at this point in the history
When a new TYPO3 installation is set up, the user can choose
to "create a first site" (page with sys_template). In this step,
it should be important that a site configuration should be created
as well, in order to use site handling right out-of-the-box.

Therefore, this step in the installer now also creates a site
configuration (identifier "main") with one language english
to get started.

Resolves: #87383
Releases: master, 9.5
Change-Id: Ib8ef27c076d8ed24bfeb015aea52bdcf4ec0432c
Reviewed-on: https://review.typo3.org/59391
Reviewed-by: Steffen Dietrich <Teilzeitphilosoph@gmx.de>
Tested-by: Steffen Dietrich <Teilzeitphilosoph@gmx.de>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
bmack authored and maddy2101 committed Jan 11, 2019
1 parent c9a62cd commit a65c5c3
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions typo3/sysext/install/Classes/Controller/InstallerController.php
Expand Up @@ -21,6 +21,7 @@
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash;
Expand All @@ -39,6 +40,7 @@
use TYPO3\CMS\Core\FormProtection\InstallToolFormProtection;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Package\PackageInterface;
Expand Down Expand Up @@ -798,6 +800,8 @@ public function executeDefaultConfigurationAction(ServerRequestInterface $reques
For each website you need a TypoScript template on the main page of your website (on the top level). For better maintenance all TypoScript should be extracted into external files via <INCLUDE_TYPOSCRIPT: source="FILE:EXT:site_myproject/Configuration/TypoScript/setup.typoscript">.'
]
);

$this->createSiteConfiguration('main', (int)$pageUid, $request);
break;
}

Expand Down Expand Up @@ -1191,4 +1195,52 @@ protected function loadExtLocalconfDatabaseAndExtTables()
\TYPO3\CMS\Core\Core\Bootstrap::loadBaseTca(false);
\TYPO3\CMS\Core\Core\Bootstrap::loadExtTables(false);
}

/**
* Creates a site configuration with one language "English" which is the de-facto default language for TYPO3 in general.
*
* @param string $identifier
* @param int $rootPageId
* @param ServerRequestInterface $request
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
protected function createSiteConfiguration(string $identifier, int $rootPageId, ServerRequestInterface $request)
{
$normalizedParams = $request->getAttribute('normalizedParams', null);
if (!($normalizedParams instanceof NormalizedParams)) {
$normalizedParams = new NormalizedParams(
$request->getServerParams(),
$GLOBALS['TYPO3_CONF_VARS']['SYS'],
Environment::getCurrentScript(),
Environment::getPublicPath()
);
}

// Create a default site configuration called "main" as best practice
$siteConfiguration = GeneralUtility::makeInstance(
SiteConfiguration::class,
Environment::getConfigPath() . '/sites'
);
$siteConfiguration->write($identifier, [
'rootPageId' => $rootPageId,
'base' => $normalizedParams->getSiteUrl(),
'languages' => [
0 => [
'title' => 'English',
'enabled' => true,
'languageId' => 0,
'base' => '/en/',
'typo3Language' => 'default',
'locale' => 'en_US.UTF-8',
'iso-639-1' => 'en',
'navigationTitle' => 'English',
'hreflang' => 'en-us',
'direction' => 'ltr',
'flag' => 'us',
],
],
'errorHandling' => [],
'routes' => [],
]);
}
}

0 comments on commit a65c5c3

Please sign in to comment.