Skip to content

Commit

Permalink
[BUGFIX] Correctly re-import extension static-data
Browse files Browse the repository at this point in the history
The ext_tables_static+adt.sql data are now re-imported,
if its data changed, when setting up the extensions.

This happens either from within the Extension Manager,
or via the CLI  command.

Moreover, a legacy value, which was already taken care of
in `ReloadSqlDataViewHelper`, is now respected as well.

Resolves: #102376
Releases: main, 12.4
Change-Id: I67074f8b98acd0bbfc7ce03732b18f759e1d81de
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82043
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
liayn authored and lolli42 committed Nov 29, 2023
1 parent dffc2cf commit e5bc06b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
Expand Up @@ -459,13 +459,19 @@ protected function importStaticSqlFile(string $extensionKey, $packagePath)
{
$extTablesStaticSqlFile = $packagePath . 'ext_tables_static+adt.sql';
$extTablesStaticSqlRelFile = PathUtility::stripPathSitePrefix($extTablesStaticSqlFile);
if (!$this->registry->get('extensionDataImport', $extTablesStaticSqlRelFile)) {
$shortFileHash = '';
if (file_exists($extTablesStaticSqlFile)) {
$extTablesStaticSqlContent = (string)file_get_contents($extTablesStaticSqlFile);
$shortFileHash = md5($extTablesStaticSqlContent);
$oldHash = $this->registry->get('extensionDataImport', $extTablesStaticSqlRelFile);
$shortFileHash = '';
// We used to only store "1" in the database when data was imported
$needsUpdate = !$oldHash || $oldHash === 1;
if (file_exists($extTablesStaticSqlFile)) {
$extTablesStaticSqlContent = (string)file_get_contents($extTablesStaticSqlFile);
$shortFileHash = md5($extTablesStaticSqlContent);
$needsUpdate = $oldHash !== $shortFileHash;
if ($needsUpdate) {
$this->importStaticSql($extTablesStaticSqlContent);
}
}
if ($needsUpdate) {
$this->registry->set('extensionDataImport', $extTablesStaticSqlRelFile, $shortFileHash);
$this->eventDispatcher->dispatch(new AfterExtensionStaticDatabaseContentHasBeenImportedEvent($extensionKey, $extTablesStaticSqlFile, $this));
}
Expand Down

0 comments on commit e5bc06b

Please sign in to comment.