Skip to content

Fix engine-mods leaking due to view created twice in templates - #29

Merged
ericges merged 4 commits into
mainfrom
fix/engine-mod-leak
Jul 27, 2026
Merged

Fix engine-mods leaking due to view created twice in templates#29
ericges merged 4 commits into
mainfrom
fix/engine-mod-leak

Conversation

@ericges

@ericges ericges commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors and simplifies the Flare ListView templates and related backend logic, aiming for better template inheritance, more modularity, and improved event handling in query building. The most important changes are summarized below.

Template Refactoring and Simplification:

  • Several ListView-related templates (list_only.html.twig, form_only.html.twig, filter_only.html.twig, pagination_only.html.twig, paginator_only.html.twig) now extend the main flare_listview.html.twig template, removing duplicate code and centralizing logic. This makes the templates more maintainable and modular [1] [2] [3] [4] [5].

Backend Logic Improvements:

  • The createView() method in Engine.php now always clones the engine instance, ensuring modifications are isolated and preventing side effects from shared state.
  • The createQueryBuilder() method in ListQueryDirector.php now correctly dispatches and uses the ModifyListQueryStructEvent, ensuring that any event-driven modifications to the query structure are applied before building the final query.

Code Cleanliness:

  • Removed an unnecessary PHPStan ignore comment from Configuration.php, cleaning up the codebase.This pull request refactors how the flare_list view is created and passed to Twig templates, and fixes an issue with event handling in the query builder. The main goals are to ensure the flare_list is only created once and reused across templates, and to correctly dispatch and use events when building queries.

Template refactoring and view initialization:

  • Ensured flare_list is only created if not already set, preventing redundant calls to flare.createView in flare_listview.html.twig (contao/templates/content_element/flare_listview.html.twig).
  • Removed duplicate flare_list initialization from partial templates (form_only.html.twig, list_only.html.twig, paginator_only.html.twig), assuming it is now provided by the parent template (contao/templates/content_element/flare_listview/form_only.html.twig, [1] [2].

Engine logic update:

  • Changed createView() in Engine.php to always clone the engine instance, simplifying and making view creation more consistent (src/Engine/Engine.php).

Event handling and query building:

  • Fixed event dispatching in ListQueryDirector.php to use the modified event object and ensure the latest queryStruct is used when creating the query builder (src/Query/Executor/ListQueryDirector.php).

@heimrich-hannot heimrich-hannot changed the title Refactor query dispatching and streamline view initialization Fix engine-mods leaking due to view created twice in templates Jul 27, 2026
@ericges
ericges merged commit bb7fe0f into main Jul 27, 2026
13 checks passed
@ericges
ericges deleted the fix/engine-mod-leak branch July 27, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant