featdd / dpn_glossary

Glossary extension for TYPO3

Home Page:http://typo3.org/extensions/repository/view/dpn_glossary

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

More than one synonym not parsed

kayATcu opened this issue · comments

Hi,

we have typo3 version 12 and use this extension in the newest version.

But if i have more than one "synonyms", it will underline only the first synonym in frontend and not the others.
2024-02-29_15-33

Best regards,
Kay

Hi @kayATcu,

have you set a max replacement limit?

Greetings
Daniel

@featdd no. Everything is default.
grafik
2024-02-29_16-18
2024-02-29_16-18_1

@featdd i think i found the problem and a solution....

--- vendor/featdd/dpn-glossary/Classes/Service/ParserService.php	2024-02-18 21:15:02.000000000 +0100
+++ patches/ParserService-new.php	2024-03-01 11:10:00.536245476 +0100
@@ -405,8 +405,9 @@
 
             if ($isParseSynonyms) {
                 $synonymTermObject = clone $termObject;
+                $allSynonyms = $termObject->getSynonyms()->toArray();
                 /** @var \Featdd\DpnGlossary\Domain\Model\Synonym $synonym */
-                foreach ($termObject->getSynonyms() as $synonym) {
+                foreach ($allSynonyms as $synonym) {
                     $synonymTermObject->{
                     ($this->settings['useTermForSynonymParsingDataWrap'] ?? false)
                         ? 'setParsingName'

Greetings,
Kay

Hi @kayATcu,

I couldn't believe my eyes first when I reproduced this and struggled to find an explanation, this is really a fine piece of an edge case. 😅

The issue was that I build a nested iteration over the synonym ObjectStorage, because inside the iteration the parser calls the "__toArray()" function of the term, wich also iterates over the ObjectStorage.
This is resulting in an array reset inside the ObjectStorage's internal array, messing up the overlaying iteration and so on...

Anyway here's the fix: 86a5767

I will also prepare an update for the TER.

Greetings
Daniel