Closed (fixed)
Project:
Drupal core
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
4 Feb 2004 at 21:12 UTC
Updated:
26 Jun 2005 at 00:15 UTC
Jump to comment: Most recent file
Changing the name of the anonymous user in admin->config changes the value of variable "anonymous" (variable table) but does not set the name value of UID 0 in the users table. The node display routines use users.name for the value to display, as does the watchdog event log.
I suspect that now that we have a dedicated UID 0 for the anonymous user, the anonymous entry in the variable table could go away. Is there any reason why it is needed?
It would be easy enough to fix the code to store the config value for the anonymous user in both places, but duplicating it seems like a bad idea.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | anonymous_user.patch | 14.01 KB | Chris Johnson |
| #3 | anonymous_name.patch | 8.73 KB | Chris Johnson |
Comments
Comment #1
matt westgate commentedYou can find some history why we don't set the anonymous info in the database here.
Comment #2
Chris Johnson commentedYes, and that was the wrong solution.
All checks for the anonymous user should be checking for uid == 0, and not the name.
Putting a NULL in users.name for users.uid == 0 causes problems elsewhere.
Comment #3
Chris Johnson commentedSuggested patch attached.
1. Refactor common.inc::format_name() to only format the name and do nothing else.
2. Add theme hook theme.inc::theme_format_name() to allow formatting of author name by theme, e.g. if theme needs to shorten long names or theme designer wants to otherwise modify them.
3. Modify system.module::system_view_general() and system_settings_save() to use the {users} table name value for the anonymous user instead of a value in the {variables} table.
4. Create update_78() to set the name field in {users} to the current Anonymous users name for uid 0.
5. Modify database/database.*sql to correctly create the initial {users} table entry for the anonymous user.
Comment #4
gábor hojtsyI agree with Chris. Since we have a database row for UID 0, we can store the username there. The setting change is a bit hackish though... And SQL code is written with all uppercase keywords and all lowercase column names thoughout Drupal... This patch does not conform to this style.
Comment #5
Chris Johnson commentedYeah, the setting method is kind of ugly because the system module assumes[1] that all system settings will of course only ever be in the {variable} table.
One alternative I thought about was moving the setting of the anonymous user name to some other place where a hack would not be required, but there did not seem to be a better logical place for such a global setting.
I am open to suggestions on how to better set the anonymous name in the {users} table.
As for the SQL -- that's obviously a 5 second fix.
[1] we have an expression in the U.S. that plays with the word "assume" to create a phrase to remind people not to make assumptions, as they are nearly always wrong.
Comment #6
gábor hojtsyI always expected it to be at /admin/system/modules/user, since it is a user setting :) That does not make much difference in coding, since this is also handled with vaiarble storage, but still it seems to be more logical IMHO.
Comment #7
Chris Johnson commentedNew patch attached.
1. Refactor common.inc::format_name() to only format the name and do nothing else.
2. Add theme hook theme.inc::theme_format_name() to allow formatting of author name by theme, e.g. if theme needs to shorten long names or theme designer wants to otherwise modify them.
3. Remove setting of anonymous user name in the {variable} table in the system module.
4. Create update_79() to set the name field in {users} to the current Anonymous users name for uid 0.
5. Modify database/database.*sql to correctly create the initial {users} table entry for the anonymous user.
6. Add link to admin/user/edit/0 in both admin/config (legacy location) and admin/config/modules/user (per Goba's suggestion).
7. Fix user.module to prevent deletion of uid 0.
8. Modify user.module to present only those form items which it is sane to change for uid 0.
Over all goal: remove variable "anonymous" and instead use the users table entry for anonymous for the displayed name, to make it less confusing and cleaner.
Comment #8
dries commentedThis patch does no longer apply but looks good otherwise. Changing its status to 'active'.
Comment #9
robin monks commentedI'm going to try to revive this old patch. I'm sure some of this has alreay been accomplished in other patches, but it's well worth a looksy.
Robin
Comment #10
robin monks commentedAs far as I can see in my tests, the system has been /almost/ completly weened off of
variable_get("anonymous", "Anonymous")in favor of $user->name. The remaining uses of this variable seem to be justified as "last resort" uses and the replacement of those is outside the scope of the bug (should they need to be replaced et al).Robin
Comment #11
(not verified) commented