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.
This function can run multiple times on a page, so cache the results to avoid db load.
Comment | File | Size | Author |
---|---|---|---|
#4 | domain_source_lookup_static-934636-4.patch | 1.33 KB | gdud |
#1 | 934636-static-lookup.patch | 2.28 KB | agentrickard |
Comments
Comment #1
agentrickardPatch against 6--2. Note that we force refresh during node validation.
Comment #2
agentrickardCommitted to 6.x.2, 7.x.2 and HEAD.
Comment #4
gdud CreditAttribution: gdud commentedIn some cases using static cache by domain_source_lookup() produces some wrong behaviour.
For example, when you are using CNR 6.x-4.1 module, after adding new node on domain X (X > 0) user is redirected to main domain (0).
I looked deeper in the codes of these two modules and I identified the problem:
domain_source_lookup() is execute twice during the node_save().
First by node_load() in corresponding_node_references_insert(). This leads to generate static cache using main domain (0) as value. This happen because proper value of domain source not save into {domain_source} table yet and default domain source is used.
When domain_source_lookup() is execute second time by Domain module to prepare node path, wrong value is given from static cache.
In my opinion, domain_source_lookup() should use static cache only for values fetched directly from database (not for default values).
In patch bellow is my modifications to domain_source_lookup().
Comment #5
agentrickardI can see the reasoning here. Needs to apply to 7.x.3 first.
Comment #6
agentrickard