Unneeded user_load() call in Node author content type

Created on 5 May 2023, about 1 year ago

Problem/Motivation

ctools/plugins/content_types/node_context/node_author.inc loads the user object ($user = user_load($node->uid)) in ctools_node_author_content_type_render() to pass to theme_username() 'account' parameter. However theme_username() will work just fine with a node object being passed as the value of 'account' (see template_preprocess_node() which does exactly that).

Since Drupal 7 does not do a full user entity load when loading a node (user_node_load() tries to add only what is commonly needed in as efficient way as possible), this might mean on sites that generate large teaser listings built with Panelizer that uses the Node author pane could be inefficiently doing a lot of user entity loading if many different authors are present on the page. Seeing as no one has ever complained about panelized teasers being dead slow (I certainly have not and have used them extensively) it probably won't change the world but may be a nice to have late in its lifetime optimisation for CTools 7 :)

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom magicmyth

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024