According to http://drupal.org/coding-standards, all functions should be prefixed with the module name and "internal" functions should begin with an underscore.
In HEAD, we currently have multiple prefixes and few functions without any prefixes
- disallow_anon_access
- pm_xy
- private_message_xy
- privatemsg_xy
(in privatemsgapi.inc there are two functions called _save_privatemsg_group_xy, but they are never used and should imho be removed anyway because they refer inexistent tables)
I'd suggest to use privatemsg_xy everywhere and add a _ prefix to internal functions.
Further steps/ideas about cleanup/"global refactoring"
- move internal functions to privatemsgapi.inc
- move all "menu-functions" into an own file, privatemsg.pages.inc, to save parsing time if they are not used. That's how core does it, too...
No patch yet, would like to get some feedback/other ideas first...
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | privatemsg_split.patch | 107.74 KB | berdir |
Comments
Comment #1
naheemsays commentedIs there a point in keeping the separate privatemsgapi.inc file?
Would it not be just as well to move all that stuff into the module file? it is always loaded, so there does not seem to be too much difference.
as for function naming, I would prefer privatemsg_ for public stuff, but I am not too bothered even with the current situation.
Having a privatemsg.pages.inc and a privatemsg.admin.inc would IMO be a good idea (even though the latter will currently be sparsely populated).
Comment #2
berdirThere is one case when privatemsgapi.inc doesn't get loaded, when an guest visits a site with aggressive cache enabled.
However, I don't know how often that's used and moving them into one file would save two privatemsg_setup_includes() calls and the loading of an additional file. Not sure what's better in the long term.
Comment #3
berdirWe should also rename the aliases so that it's more clear what they are... max_timestamp/max_mid and so on...
Comment #4
berdirOk, here is a patch. Let's do that now since it's going to break a lot of patches anyway.
Patch is quite big but only moves stuff around except a few function renames (those that didn't used the privatemsg prefix like private_message_... or pm_...)
Tests still pass and clicking around does work too.
Anyone up for a short tests so that I can commit this?
Comment #5
litwol commentedomg. talk about fucking with revision history...
Comment #6
berdirCommited, this needs to be done for 7.x-1.x too... Will probably be easier to just create a new patch, though..
Comment #7
berdirThis has now also been commited to 7.x-1.x-dev