denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)
Denise ([staff profile] denise) wrote in [site community profile] dw_dev2010-06-28 06:24 pm
Entry tags:

variable conventions

A comment made in Bugzilla this morning had me thinking: what are the variables we use by convention (or should use) everywhere throughout the code? I want to make a list of them so that a) people can know what they are and not re-use them for other things, and b). we can go through and change things that don't use them.

The ones I immediately thought of are:

$u: user object
$remote: remote logged-in viewer


What else is there? (And if there isn't a convention for a specific reference, and it's got five or six variable names throughout the code, mention that too, so we can standardize.)
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2010-06-29 01:04 am (UTC)(link)
$u probably should be changed to read "user space page currently being used" or the like ( or we should have something else for that v.s. some random user object we're just playing with )
Edited 2010-06-29 01:04 (UTC)
kareila: (Default)

[personal profile] kareila 2010-06-29 02:52 am (UTC)(link)
I've also seen $r for the active web request, but that's not as heavily used.

Sometimes $cu (community u) or $ju (journal u) is used to distinguish the journal being posted in from the user doing the posting.
alierak: (Default)

[personal profile] alierak 2010-06-29 03:47 am (UTC)(link)
$dbh: db handle for global master write access
$dbr: db handle for global cluster read access
$dbcr: db handle for user cluster read access
$dbcm: db handle for user master write access (and sometimes read, maybe used incorrectly)
$db: db handle for unspecified use (avoid if possible)
$sth: prepared statement handle
exor674: Computer Science is my girlfriend (Default)

[personal profile] exor674 2010-06-29 07:08 am (UTC)(link)
IIRC the distinction between db.*[hm] and db.*r doesn't matter on DW as everything's a dual-master setup.
But theoretically, if you will have issues with older data, don't use dbr/dbcr, and if you need the newest data or have to write, you must use dbh/dbcm

( dbr/dbcr would be the slave, dbh/dbcm would be the master )
alierak: (Default)

[personal profile] alierak 2010-06-29 05:33 pm (UTC)(link)
Found Mark's post I was thinking of when I made this comment.
alierak: (Default)

[personal profile] alierak 2010-06-29 04:06 am (UTC)(link)
$memkey: key for a memcache entry
$mogkey: key for a mogilefs entry
$key: could be either of the above, avoid if possible?
yvi: Kaylee half-smiling, looking very pretty (Default)

[personal profile] yvi 2010-06-29 07:15 am (UTC)(link)
$journal and $poster for the journal an entry is in and the user who posted it.