Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
At the moment, when altering the language switcher links with the translated URL alias, all the facets are always loaded and a nested loop occurs for each facet and language. This can become quite slow on sites with many facets and many languages as all the facets are loaded on each authenticated page request since the language switcher links are not cached.
Steps to reproduce
Proposed resolution
Cache the data the alter needs to replace the filter URL aliases.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#3 | 3198510-3.patch | 9.88 KB | Upchuk |
Comments
Comment #2
Upchuk CreditAttribution: Upchuk at European Commission and European Union Institutions, Agencies and Bodies, WEBOMELETTE commentedComment #3
Upchuk CreditAttribution: Upchuk at European Commission and European Union Institutions, Agencies and Bodies, WEBOMELETTE commentedHere is an attempt at improving this.
I made a service where we do a first iteration and cache the info needed for the facet URL aliases (translated alias, segment, filter key) and we cache this. Any subsequent calls to
facets_language_switch_links_alter
will deal only with this cached array of data rather than always having to load facets and reconstruct stuff.Initially I thought that tests were missing for this but i saw they are there (created in #2893374).
Comment #4
borisson_This is hard to review because there is not a big overlap with the current files. @Upchuk explained what they were going to do before this patch arrived. It looks like a good idea.
Comment #6
borisson_Comment #7
Chewie CreditAttribution: Chewie for European Commission and European Union Institutions, Agencies and Bodies commentedIt would be better to check that this service exists especially if we introducing it in this change.
Unnecessary line.
I can confirm that changes look good for me and really improving performance.
Comment #9
droddis CreditAttribution: droddis commentedHi there, Does anyone know if this has been rolled into 1.8, or should we be using the dev version? If not, have there been enough changes that we should not implement on the production version of 1.8?
I've been a bit worried about the security update from 1.6 to 1.8.
thanks in advance,
David