Skip to content

Commit 264c25a

Browse files
stollrphansys
authored andcommitted
Documented the usage of refresh query hint if cache is used for translatable (#1021)
If query caching is enabled the TranslationWalker won't be used anymore once the query is cached. Therefore the `Query::HINT_REFRESH` won't be set automatically. This leads to the issue, that once a translateable entity is loaded a second query with another locale won't update the translateable properties in the entity. Adding the `Query::HINT_REFRESH` manually to the query will fix the issue.
1 parent fe0d0e5 commit 264c25a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/translatable.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ $query->setHint(
506506
\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK,
507507
1 // fallback to default values in case if record is not translated
508508
);
509+
// refresh entities
510+
$query->setHint(
511+
\Doctrine\ORM\Query::HINT_REFRESH,
512+
true // update entity with correct locale if it was already loaded before
513+
);
509514

510515
$articles = $query->getResult(); // object hydration
511516
```

0 commit comments

Comments
 (0)