Skip to content

Commit

Permalink
Merge pull request #556 from Yoast/bugfix/premium-migration-fix
Browse files Browse the repository at this point in the history
[BUGFIX] Filter the columns to import from the old premium database table before inserting in the new table within MigratePremiumFocusKeywords
  • Loading branch information
RinyVT authored Sep 18, 2023
2 parents 4dc99b9 + 14f6e26 commit 99182a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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

0 comments on commit 99182a0

Please sign in to comment.