Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Filter the columns to import from the old premium database table before inserting in the new table within MigratePremiumFocusKeywords #556

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ We will follow [Semantic Versioning](http://semver.org/).
- Show warning on linking suggestions when content element is set to "All Languages" instead of fatal exception
- Added extra checks within the metatag generators in case fields do not exist (opengraph, twitter, robots)
- `hasSitemapFields` now correctly returns the `sitemapFields` instead of `yoastSeoFields`
- Filter the columns to import from the old premium database table before inserting in the new table within `MigratePremiumFocusKeywords`

## 9.0.1 July 6, 2023
### Fixed
Expand Down
18 changes: 13 additions & 5 deletions Classes/Updates/MigratePremiumFocusKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Doctrine\DBAL\Exception;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
Expand Down Expand Up @@ -43,6 +42,7 @@ public function getDescription(): string
public function executeUpdate(): bool
{
$premiumFocusKeywords = $this->getPremiumFocusKeywords();
$relatedTableColumns = $this->getRelatedTableColumns();
foreach ($premiumFocusKeywords as $premiumFocusKeyword) {
$premiumFocusKeyword['uid_foreign'] = $premiumFocusKeyword['parentid'];
$premiumFocusKeyword['tablenames'] = $premiumFocusKeyword['parenttable'];
Expand All @@ -51,11 +51,11 @@ public function executeUpdate(): bool
$premiumFocusKeyword['parentid'],
$premiumFocusKeyword['parenttable']
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 11) {
unset($premiumFocusKeyword['cruser_id']);
}
$this->connectionPool->getConnectionForTable(self::NEW_TABLE)
->insert(self::NEW_TABLE, $premiumFocusKeyword);
->insert(
self::NEW_TABLE,
array_intersect_key($premiumFocusKeyword, $relatedTableColumns)
);
}

$this->connectionPool->getConnectionForTable('pages')
Expand All @@ -77,6 +77,14 @@ protected function getPremiumFocusKeywords(): array
return GeneralUtility::makeInstance(DbalService::class)->getAllResults($statement);
}

protected function getRelatedTableColumns(): array
{
$columns = $this->connectionPool->getConnectionForTable(self::NEW_TABLE)
->getSchemaManager()
->listTableColumns(self::NEW_TABLE);
return array_flip(array_keys($columns));
}

protected function premiumTableExists(): bool
{
try {
Expand Down