• 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/Service/SaveScoresService.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\Service;
13

14
use Doctrine\DBAL\Exception;
15
use TYPO3\CMS\Core\Database\Connection;
16
use TYPO3\CMS\Core\Database\ConnectionPool;
17
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
18
use YoastSeoForTypo3\YoastSeo\Constants\TableNames;
19

20
class SaveScoresService
21
{
22
    public function __construct(
23
        protected ConnectionPool $connectionPool
NEW
24
    ) {}
×
25

26
    /**
27
     * @param array<string, string> $data
28
     */
29
    public function save(array $data): void
30
    {
31
        try {
NEW
32
            $record = $this->getRecord($data);
×
NEW
33
        } catch (\Exception) {
×
NEW
34
            return;
×
35
        }
36

NEW
37
        if ($record === null || !isset($data['readabilityScore'], $data['seoScore'])) {
×
NEW
38
            return;
×
39
        }
40

NEW
41
        $connection = $this->connectionPool->getConnectionForTable($data['table']);
×
NEW
42
        $connection->update($data['table'], [
×
NEW
43
            'tx_yoastseo_score_readability' => (string)$data['readabilityScore'],
×
NEW
44
            'tx_yoastseo_score_seo' => (string)$data['seoScore'],
×
NEW
45
        ], ['uid' => (int)$record['uid']]);
×
46
    }
47

48
    /**
49
     * @param array<string, string> $data
50
     * @return array<string, int|string>|null
51
     * @throws Exception
52
     */
53
    protected function getRecord(array $data): ?array
54
    {
NEW
55
        if ($data['table'] === TableNames::PAGES) {
×
NEW
56
            return $this->getPageRecord((int)$data['uid'], (int)($data['languageId'] ?? 0));
×
57
        }
58

NEW
59
        $connection = $this->connectionPool->getConnectionForTable($data['table']);
×
NEW
60
        $record = $connection->select(
×
NEW
61
            ['uid'],
×
NEW
62
            $data['table'],
×
NEW
63
            ['uid' => (int)$data['uid']],
×
NEW
64
        )->fetchAssociative();
×
NEW
65
        return $record === false ? null : $record;
×
66
    }
67

68
    /**
69
     * @return array<string, int|string>|null
70
     * @throws Exception
71
     */
72
    protected function getPageRecord(int $pageUid, int $languageId): ?array
73
    {
NEW
74
        $queryBuilder = $this->connectionPool->getQueryBuilderForTable(TableNames::PAGES);
×
NEW
75
        $queryBuilder->getRestrictions()->removeAll()->add(new DeletedRestriction());
×
NEW
76
        $queryBuilder->select('uid', 'tx_yoastseo_disable_analysis')->from(TableNames::PAGES);
×
NEW
77
        if ($languageId > 0) {
×
NEW
78
            $queryBuilder->where(
×
NEW
79
                $queryBuilder->expr()->and(
×
NEW
80
                    $queryBuilder->expr()->eq(
×
NEW
81
                        $GLOBALS['TCA'][TableNames::PAGES]['ctrl']['transOrigPointerField'],
×
NEW
82
                        $queryBuilder->createNamedParameter($pageUid, Connection::PARAM_INT)
×
NEW
83
                    ),
×
NEW
84
                    $queryBuilder->expr()->eq(
×
NEW
85
                        $GLOBALS['TCA'][TableNames::PAGES]['ctrl']['languageField'],
×
NEW
86
                        $queryBuilder->createNamedParameter($languageId, Connection::PARAM_INT)
×
NEW
87
                    ),
×
NEW
88
                    $queryBuilder->expr()->eq('tx_yoastseo_disable_analysis', 0),
×
NEW
89
                )
×
NEW
90
            );
×
91
        } else {
NEW
92
            $queryBuilder->where(
×
NEW
93
                $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($pageUid, Connection::PARAM_INT)),
×
NEW
94
                $queryBuilder->expr()->eq('tx_yoastseo_disable_analysis', 0),
×
NEW
95
            );
×
96
        }
NEW
97
        $record = $queryBuilder->executeQuery()->fetchAssociative();
×
NEW
98
        return $record === false ? null : $record;
×
99
    }
100
}
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