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.

CommentFileSizeAuthor
#1 nodeloadjv.patch1.03 KBjvandyk
node_load_5.patch924 bytesrobertDouglass
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jvandyk’s picture

FileSize
1.03 KB

Here'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.

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks folks.

killes@www.drop.org’s picture

Version: 5.x-dev » 4.7.x-dev

backported.

Anonymous’s picture

Status: Fixed » Closed (fixed)