Project

General

Profile

Actions

Bug #89165

closed

Metatags set with metatag manager registry wont be rendered if a plugin action is uncached

Added by Daniel Dorndorf about 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
SEO
Target version:
-
Start date:
2019-09-13
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I got the issue that the meta tags I set via the new meta tag api in my controller were not set.

There seems to be an Issue when the action is uncached and a proper instantiating of the page renderer using the added metatags etc.

I wasn't able to find out more details yet, I may edit this later, but maybe this gives someone a direction to the location of the problem.

Greetings
Daniel

Actions #1

Updated by Michael Stucki about 5 years ago

  • Project changed from 9 to TYPO3 Core
  • TYPO3 Version set to 10

Wrong project.

Actions #2

Updated by Christian Eßl about 5 years ago

  • Category set to SEO
Actions #3

Updated by Richard Haeser about 5 years ago

Hi Daniel,

In my own setup I don't have any problems with this. So I do have some questions for you:

- Which version of TYPO3 do you use?
- Do you have a snippet of the code that is setting your metatag by the API?
- Is it a metatag that is also set by other plugins or by page settings?

Thanks,

Richard

Actions #4

Updated by Richard Haeser about 5 years ago

  • Status changed from New to Needs Feedback
Actions #5

Updated by Daniel Dorndorf about 5 years ago

Hi Richard,

I'm using TYPO3 9.5.10

I created a MetaTagService which gets the MetaTagManagerRegistry via inject method (but I also tried it manually with the ObjectManager):

/**
 * @var \TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry
 */
protected $metaTagManagerRegistry;

/**
 * @param \TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry $metaTagManagerRegistry
 */
public function injectMetaTagManagerRegistry(MetaTagManagerRegistry $metaTagManagerRegistry)
{
    $this->metaTagManagerRegistry = $metaTagManagerRegistry;
}

Example for "description"-Tag:

$this->metaTagManagerRegistry->getManagerForProperty('description')->addProperty('description', $description, [], true);

In an uncached action the MetaTagManagers properties in the page renderer wont be replaced, the value set by the page settings will be used.
For me it seems like something with the singleton instance isn't working properly, because in my understanding the MetaTagManagerRegistry in the PageRenderer and in my service should be the same object, but they are not.

Greetings
Daniel

Actions #6

Updated by Richard Haeser about 5 years ago

Can you try it like:

        $metaTagManagerRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);

        $ogMetaTagManager = $metaTagManagerRegistry->getManagerForProperty('og:title');
        $ogMetaTagManager->addProperty('og:title', 'Entry from uncached plugin', [], true);

This works for me even on mixed pages. On mixed pages the uncached plugin will always overrule the other cached data.

Actions #7

Updated by Daniel Dorndorf about 5 years ago

It worked... but why?

Is there enough time or operations between calling the constructor and the action using the registry, that there's a difference?
(I also instanciated the registry via GeneralUtility but in the constructor)

Maybe I'm lacking knowledge about singleton instances and the core, or is there an issue deep down the rabbit hole?

Actions #8

Updated by Richard Haeser about 5 years ago

Even with GeneralUtility you had this problem? Maybe something was wrong with the injection? Should work as far as I know.

Actions #9

Updated by Daniel Dorndorf about 5 years ago

I have no hooks or anything special, just moved everything in a service class and used dependency injection

Actions #10

Updated by Susanne Moog over 4 years ago

  • Status changed from Needs Feedback to Closed

Just tried to reproduce the issue and failed to do so, worked for me both with DI and with GeneralUtility. I'm going to close the issue - please report back if it happens again - ideally with an example extension / code.

Actions

Also available in: Atom PDF