• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / Yoast-SEO-for-TYPO3 / 24723291290

21 Apr 2026 12:50PM UTC coverage: 10.457% (+9.2%) from 1.275%
24723291290

push

github

web-flow
Merge pull request #632 from Yoast/feature/yoast-v12

[FEATURE] Version 12.0.0, added v14 support, removed v11 support including php8.0 and php8.1, rewrote backend javascript functionality to typescript and webcomponents

40 of 806 new or added lines in 69 files covered. (4.96%)

40 existing lines in 23 files now uncovered.

284 of 2716 relevant lines covered (10.46%)

0.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/Updates/MigratePremiumFocusKeywords.php
1
<?php
2

3
/**
4
 * This file is part of the "yoast_seo" extension for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.txt file that was distributed with this source code.
8
 */
9

10
declare(strict_types=1);
11

12
namespace YoastSeoForTypo3\YoastSeo\Updates;
13

14
use Doctrine\DBAL\Exception;
15
use TYPO3\CMS\Core\Database\ConnectionPool;
16
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
19
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
20
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
21
use YoastSeoForTypo3\YoastSeo\Constants\TableNames;
22

23
#[UpgradeWizard('yoastPremiumFocusKeywordsMigrate')]
24
class MigratePremiumFocusKeywords implements UpgradeWizardInterface
25
{
26
    protected const PREMIUM_TABLE = 'tx_yoast_seo_premium_focus_keywords';
27
    protected const NEW_TABLE = TableNames::RELATED_FOCUSKEYWORD;
28
    protected ConnectionPool $connectionPool;
29

30
    public function __construct()
31
    {
32
        $this->connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
×
33
    }
34

35
    public function getIdentifier(): string
36
    {
37
        return 'yoastPremiumFocusKeywordsMigrate';
×
38
    }
39

40
    public function getTitle(): string
41
    {
42
        return 'Yoast SEO for TYPO3 - Migrate premium focus keywords';
×
43
    }
44

45
    public function getDescription(): string
46
    {
47
        return 'Migrate focus keywords from the premium extension';
×
48
    }
49

50
    public function executeUpdate(): bool
51
    {
52
        $premiumFocusKeywords = $this->getPremiumFocusKeywords();
×
53
        $relatedTableColumns = $this->getRelatedTableColumns();
×
54
        foreach ($premiumFocusKeywords as $premiumFocusKeyword) {
×
55
            $premiumFocusKeyword['uid_foreign'] = $premiumFocusKeyword['parentid'];
×
56
            $premiumFocusKeyword['tablenames'] = $premiumFocusKeyword['parenttable'];
×
57
            unset(
×
58
                $premiumFocusKeyword['uid'],
×
59
                $premiumFocusKeyword['parentid'],
×
60
                $premiumFocusKeyword['parenttable']
×
61
            );
×
62
            $this->connectionPool->getConnectionForTable(self::NEW_TABLE)
×
63
                ->insert(
×
64
                    self::NEW_TABLE,
×
65
                    array_intersect_key($premiumFocusKeyword, $relatedTableColumns)
×
66
                );
×
67
        }
68

NEW
69
        $this->connectionPool->getConnectionForTable(TableNames::PAGES)
×
70
            ->executeQuery(
×
71
                'UPDATE pages SET tx_yoastseo_focuskeyword_related = tx_yoastseo_focuskeyword_premium'
×
72
            );
×
73

74
        return true;
×
75
    }
76

77
    protected function getPremiumFocusKeywords(): array
78
    {
79
        $queryBuilder = $this->connectionPool->getQueryBuilderForTable(self::PREMIUM_TABLE);
×
80
        $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
×
81
        return $queryBuilder
×
82
            ->select('*')
×
83
            ->from(self::PREMIUM_TABLE)
×
84
            ->executeQuery()
×
85
            ->fetchAllAssociative();
×
86
    }
87

88
    protected function getRelatedTableColumns(): array
89
    {
90
        $connection = $this->connectionPool->getConnectionForTable(self::NEW_TABLE);
×
91
        if (method_exists($connection, 'getSchemaManager')) {
×
92
            $schemaManager = $connection->getSchemaManager();
×
93
        } else {
94
            $schemaManager = $connection->createSchemaManager();
×
95
        }
96
        $columns = $schemaManager->listTableColumns(self::NEW_TABLE);
×
97
        return array_flip(array_keys($columns));
×
98
    }
99

100
    protected function premiumTableExists(): bool
101
    {
102
        try {
103
            $connection = $this->connectionPool->getConnectionForTable(self::PREMIUM_TABLE);
×
104
            if (method_exists($connection, 'getSchemaManager')) {
×
105
                $schemaManager = $connection->getSchemaManager();
×
106
            } else {
107
                $schemaManager = $connection->createSchemaManager();
×
108
            }
109
            return $schemaManager->tablesExist([self::PREMIUM_TABLE]);
×
110
        } catch (Exception $e) {
×
111
            return false;
×
112
        }
113
    }
114

115
    public function updateNecessary(): bool
116
    {
117
        return $this->premiumTableExists();
×
118
    }
119

120
    public function getPrerequisites(): array
121
    {
122
        return [
×
123
            DatabaseUpdatedPrerequisite::class,
×
124
        ];
×
125
    }
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc