Closed (fixed)
Project:
Conditional Fields
Version:
8.x-1.0-alpha6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Oct 2019 at 10:57 UTC
Updated:
21 Mar 2026 at 18:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mindaugasd commentedComment #3
mindaugasd commentedComment #4
sboden commentedI can confirm this happening in 8.x-1.0-alpha6. It's a bug in the conditional_fields plugin discovery, discovery fails and then tries again every time while discovery was supposed to run over all installed modules only once (hence the large amount of file_exists() you see being executed) ... Currently the problem seems to be fixed in 8.x-1.x-dev as the source code was "reshuffled".
Comment #5
solide-echt commentedAFAIK this is still happening in 8.x-1.x-dev. My guess was this was due to the ConditionalFieldsHandler Annotation class not defining an @ingroup (as does for example the different views plugin classes do) but the issue is still present after adding @ingroup conditional_fields_handler_plugins to both the Annotation class and the individual handlers. I think there is a more architectural issue here: the discovery is done per field whereas in principe it should be possible to do the discovery per form.
No quick fix if that's at stake here... Digging deeper though.
Eric
Comment #6
sboden commentedAttached a patch against 8.x-1.x which solves the super slowness, but there are more issues even in that version to make conditional_fields work ok in a project.
What this particular patch changes is the way form validation is done. In our project we saw one function being called 150.000 times before this patch, and only 200 times after the patch, on a form with 200 conditionals. Before the patch, validation is done for the whole form for every field, afterwards the validation should only be done once for the whole form.
It's not that easy making a patch against alpha6 as the code was changed a lot afterwards.
Comment #7
solide-echt commentedCould not apply the patch cleanly but it wasn't hard to apply the changes by hand and it definitely improves performance a lot. Thnx for that.
To further elaborate on the architecture: I still have no clue why even field based validation is *this* slow. I've written a client specific module (for D7) that stores validations as custom entities (so we can give better feedback on what needs to be done on a form) that contains more than 100 fields and it's not slow (to be honest: it's not superfast either...). And the States API works on field level too but it's not slow and the discovery process is not run 10.000's of times.
Comment #8
sboden commentedIn alpha6 there's another performance problem, this issue https://www.drupal.org/project/conditional_fields/issues/3115279 ... For some reason the discovery of the plugins is broken, and so conditional_fields keeps trying to scan the whole filesystem under modules. I had a patch for that too, but since I started from a newer version afterwards, I forgot about that (in a newer version, that was fixed).
It will take me a little bit of time to find that patch again.
Comment #9
kris77 commentedThank a lot @sboden.
I tried your patch and it greatly improved the speed of my form.
I have 6 dependent fields built with the business_rules module.
Comment #10
socialnicheguru commentedComment #11
tbenice commentedJust re-rolling the patch against 1.x-dev to make it apply. Also applies against alpha7.
Comment #13
colanThanks for this! I got a form submission down from 1min33s to 11 seconds.
Added another commit to clean things up a bit afterwards.
I'm appreciate some insight into #3115279: Plugin handlers don't load properly. Is that still a problem? Are there any other performance issues we should be looking at?
Comment #15
baikho commented