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.
If you load nodes with node_load($nid), caching works. If you load nodes with the alternate syntax, node_load(array($params)), caching isn't used. This patch caches nodes loaded using the alternate syntax as well, since caching is one of the things that makes node_load perform well. This patch is beneficial specifically for the case where the same node is loaded first using $params, and then later using $nid. This patch still doesn't address the case where the same node is loaded twice using $params; people should just avoid that unless absoultely necessary.
Comment | File | Size | Author |
---|---|---|---|
#1 | nodeloadjv.patch | 1.03 KB | jvandyk |
node_load_5.patch | 924 bytes | robertDouglass | |
Comments
Comment #1
jvandyk CreditAttribution: jvandyk commentedHere's a slightly modified patch that simply moves the $cachable test inside the if($node->nid) test. No sense testing it twice.
Note that this patch changes behavior when the node_load() misses (i.e., you query for a node that's not there or doesn't match). Formerly we cached node misses for calls like node_load($non_existing_nid). Now we don't. I don't think that is a great loss; I'm not sure it was even ever intended.
Comment #2
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks folks.
Comment #3
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedbackported.
Comment #4
(not verified) CreditAttribution: commented