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

Yoast / Yoast-SEO-for-TYPO3 / 25732887162

12 May 2026 11:57AM UTC coverage: 11.696%. Remained the same
25732887162

Pull #655

github

web-flow
Merge 73e693a38 into e6f54b521
Pull Request #655: [BUGFIX] Do not preview website title if config.showWebsiteTitle is false

0 of 2 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

320 of 2736 relevant lines covered (11.7%)

0.57 hits per line

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

0.0
/Classes/Frontend/AdditionalPreviewData.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\Frontend;
13

14
use TYPO3\CMS\Core\SingletonInterface;
15
use TYPO3\CMS\Core\Site\Entity\Site;
16
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
19
use YoastSeoForTypo3\YoastSeo\Service\Frontend\FrontendServiceInterface;
20
use YoastSeoForTypo3\YoastSeo\Service\YoastRequestService;
21

22
class AdditionalPreviewData implements SingletonInterface
23
{
24
    /** @var array<string, mixed> */
25
    protected array $config;
26

27
    public function __construct(
28
        protected YoastRequestService $yoastRequestService,
29
        protected FrontendServiceInterface $frontendService,
30
    ) {}
×
31

32
    /**
33
     * @param array<string, mixed> $params
34
     */
35
    public function render(array &$params, object $pObj): void
36
    {
37
        $request = $GLOBALS['TYPO3_REQUEST'] ?? null;
×
38
        if ($request === null || !$this->yoastRequestService->isValidRequest($request->getServerParams())) {
×
39
            return;
×
40
        }
41

42
        $this->config = $this->frontendService->getTyposcriptConfiguration();
×
43

44
        $pageTitleConfiguration = $this->getPageTitlePrependAppend();
×
45
        setcookie('yoast-preview-tstamp', (string)time()); // To prevent caching in for example varnish
×
46
        $params['headerData']['YoastPreview'] = sprintf(
×
47
            '<meta name="x-yoast-title-config" value="%s|||%s" />',
×
48
            $pageTitleConfiguration['prepend'],
×
49
            $pageTitleConfiguration['append']
×
50
        );
×
51
    }
52

53
    protected function getWebsiteTitle(): string
54
    {
NEW
55
        if ((bool)($this->config['showWebsiteTitle'] ?? false) === false) {
×
NEW
56
            return '';
×
57
        }
58
        $request = $GLOBALS['TYPO3_REQUEST'];
×
59
        $language = $request->getAttribute('language');
×
60
        if ($language instanceof SiteLanguage && !empty($language->getWebsiteTitle())) {
×
61
            return trim($language->getWebsiteTitle());
×
62
        }
63
        $site = $request->getAttribute('site');
×
64
        if ($site instanceof Site && !empty($site->getConfiguration()['websiteTitle'] ?? '')) {
×
65
            return trim($site->getConfiguration()['websiteTitle']);
×
66
        }
UNCOV
67
        return '';
×
68
    }
69

70
    /**
71
     * @return string[]
72
     */
73
    protected function getPageTitlePrependAppend(): array
74
    {
75
        $prependAppend = ['prepend' => '', 'append' => ''];
×
76
        $siteTitle = $this->getWebsiteTitle();
×
77
        $pageTitleFirst = (bool)($this->config['pageTitleFirst'] ?? false);
×
78
        $pageTitleSeparator = $this->getPageTitleSeparator();
×
79
        // only show a separator if there are both site title and page title
80
        if (empty($siteTitle)) {
×
81
            $pageTitleSeparator = '';
×
82
        } elseif (empty($pageTitleSeparator)) {
×
83
            // use the default separator if non given
84
            $pageTitleSeparator = ': ';
×
85
        }
86

87
        if ($pageTitleFirst) {
×
88
            $prependAppend['append'] = $pageTitleSeparator . $siteTitle;
×
89
        } else {
90
            $prependAppend['prepend'] = $siteTitle . $pageTitleSeparator;
×
91
        }
92

93
        return $prependAppend;
×
94
    }
95

96
    protected function getPageTitleSeparator(): string
97
    {
98
        if (!isset($this->config['pageTitleSeparator']) || $this->config['pageTitleSeparator'] === '') {
×
99
            return '';
×
100
        }
101

102
        if (is_array($this->config['pageTitleSeparator.'] ?? null)) {
×
103
            return (string)GeneralUtility::makeInstance(ContentObjectRenderer::class)
×
104
                ->stdWrap($this->config['pageTitleSeparator'], $this->config['pageTitleSeparator.']);
×
105
        }
106

107
        return $this->config['pageTitleSeparator'] . ' ';
×
108
    }
109
}
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