Adding a static for whether users can access user profiles makes theme_username() 1/3rd faster internally, and 25% faster in total when called multiple times on a page.

CommentFileSizeAuthor
theme_username.patch1.53 KBcatch
patch.png243.75 KBcatch
head.png257.38 KBcatch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

This sort of static will be a real hassle if the active user changes during the life of the request. Thats not uncommon when performing unit tests, for example. I tend to frown on this sort of microcaching.

dahacouk’s picture

Display Name Code Sprint Saturday September 5th...

Dave Cohen and I just had a really good face to face discussion with Angie (webchick). In summary, we are going to use the Saturday code sprint to make sure that Drupal 7 will facilitate us building contributed modules to implement display names.

This may mean altering some parts of core in a very small way. If you are passionate about cleaning up "theme_username" throughout core and making it easier for contributed modules to implement display names in a clean and consistent way, then join us at DrupalCon Paris or over the wires.

Saturday September 5th 2009 10:00 to 17:00 CEST
Location: DrupalCon Paris and online elsewhere

If you use IRC then #kendra is ready and waiting for you during those times.

I'll make sure developers are kept well feed and watered. So, if you are at DrupalCon and passionate about making it easy to implement display names then get in touch.

This is pretty much our last chance for making Drupal 7 display name friendly! Let's make it happen!

Cheers Daniel

username: dahacouk on skype, jabber, irc...
Kendra Initiative - http://www.kendra.org.uk

Gribnif’s picture

In order to avoid Moshe's issue, the cache could be changed to an array, indexed on $user->uid.

dahacouk’s picture

OK. So, the strategy over the next few weeks (during code sludge) is to get theme_username() used consistently in core. From there contributed modules will be able to implement display names with more ease.

So, if you have time over next few weeks please help Dave Cohen work on the following issue:

#192056: User's raw login name should not be output directly

Many thanks,

Daniel

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Closed (duplicate)

theme_username() no longer has this code, it may well be elsewhere closing this out for now., we've also optimized user_access() a bit in the interim.