watchdog_view function will do inner join with user table when selecting messages for viewing.

I think its not right way to do it. If user was deleted error messages for that user will be hidden from administrators view.

I think it should do a right joing and if uid is NULL then display (deleted) in the user collum for the message.

Why do i think this is important here is my explanation.
I am developing module. I deleted Anonymous User by accident then I could not see any error logs that are generated by cron jobs.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Morbus Iff’s picture

FileSize
2.54 KB

I've attached a patch that handles this, both in _overview and _view - events assigned to users that were deleted will now show the translatable "(deleted user)" under the User column.

Dries’s picture

Normally, users are not able to delete the anonymous user.

Morbus Iff’s picture

Assigned: Unassigned » Morbus Iff

Dries - changing this back. The patch in question has nothing to do with the Anonymous User (the original submitter's mention of it is a red herring, and should be ignored - this has nothing to do with anonymity). The original submitter describes a situation thusly:

a) Assume user #56 logs in.
b) Assume user #56 does something watchdoggable (login, comment, etc.).
c) Assume user #56 is deleted. Now, those watchdoggable items are no longer shown.

In essence, the title: watchdog does not display log messages for deleted users.

Morbus Iff’s picture

Dries - any thoughts on this?

Morbus Iff’s picture

Priority: Normal » Critical

I'm turning this into critical, in hopes of getting it into 4.5.0. Say User #54 is being a prick and leaving zillions of comment spams. You delete User #54 cos he sucks. A week later, you notice another User has started leaving comment spams, and you have an inkling it's the same guy - the times he leaves the comments coincide with "when the brat comes home from school". Unfortunately, however, since User #54 ("where are you!?!") is deleted, you won't see any of their related log entries (even though they're still in the database), and thus, you have no way of confirming it's the same person.

Dries’s picture

Priority: Critical » Normal

This is not a critical feature: you are the first person to request it. I'm not happy with the way this patch presents information. Adding 'deleted user' makes things look cluttered. I'd simply display the name of the deleted user like we do elsewhere (consistency).

Morbus Iff’s picture

If the user is deleted, the only thing we have to go on is the saved uid from the watchdog table, right? How would we get the user's username if said user doesn't exist (for a proper uid lookup?). In fact, the absence of the record in the users table is the only reason why this Issue was created - the JOIN was failing because of it.

Steven’s picture

I don't think this patch applies anymore. Perhaps we could instead keep at least a minimal record of deleted users (i.e. name) to avoid this problem instead? I agree with Dries that "deleted user" is not very friendly. But I hate sites that don't delete you properly. Still, it would seem in the best interest to keep the partial user record around considering other modules. E.g. tracking a deleted user might be useful.

Dries’s picture

Personally, I don't feel like complicating matters just to make deleted users trackable.

If you want to track Evil Users, block them or create a 'restricted user' role to make his or her account unusable but trackable. You don't have to delete a user.

Steven’s picture

Shouldn't we then at least add a warning about this? Deleting users sounds like a very unsafe action anyway, as we do many INNER JOINs on the users table.

tedbow’s picture

Title: Watchdog does not display log messages for deleted users » Watchdog does not display log messages for deleted users, mislabeled as "Anonymous" in overview
Version: » 8.x-dev
Assigned: Morbus Iff » tedbow
Status: Closed (won't fix) » Needs review
FileSize
0 bytes

Just found this because I was having the problem of empty event detail pages in Drupal 7. The same problems exists in Drupal 8

I understand this most be a far edge case since the last comment is 2005. But it is still a bug. I also image that because of the nature of the problem other may have experienced it but not made it to this issue. Problem shows up in a new way too.

Steps to reproduce are the same #3 from 2004.

1. Create new user. Say name = user2, uid = 2
2. Sign in as user2. Add an Article
3. As admin view Recent log Message - admin/reports/dblog
4. See log entry says "article: added New Article.". User is correctly labeled "user2". Links to /user/2
5. View entry detail.

Up to this point everything is ok

Now as delete user2

6. Reload admin/reports/dblog
7. Log entry for "article: added New Article." is now attributed to "Anonymous" but still links to /user/2(page not found)
8. Click to view log details (admin/reports/event/XX)
9. Returns empty page with no content.

The main problems are

  1. The log entry is mislabeled as anonymous in the overview list.
  2. The detail for the log entry is not viewable. So you can only see the first 56 chars of the message. Because the variables are stored as a blob it is also easily viewable by looking at the mysql table.

This is especially annoying when running automated tests and in which users perform actions then are deleted in the tests. You can't use watchdog messages because all messages for the user before the delete will not be viewable from the browser.

I have attached a patch that fixes these issues.

tedbow’s picture

Whoops empty patch file!

Status: Needs review » Needs work

The last submitted patch, dblog-show-deleted_user-7428-11.patch, failed testing.

tedbow’s picture

The test failed on "testOnlyTextSummary"

Which seems to do with adding node. Not sure how the patch could affect it.

Maybe a bug, in the test?

tedbow’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, dblog-show-deleted_user-7428-11.patch, failed testing.

mgifford’s picture

Assigned: tedbow » Unassigned
Issue summary: View changes
mlahde’s picture

Status: Needs work » Closed (cannot reproduce)

I was following the steps described in #11 and couldn't reproduce the issues:
step 7. Log entry for "article: added New Article." is now attributed to "Anonymous" but still links to /user/2(page not found)
step 8. Click to view log details (admin/reports/event/XX)
step 9. Returns empty page with no content.

Now the step 7 gives 'Anynomous' as before but is not linked to /user/2 (nor anything) anymore. The steps 8 and 9 produce a normal behaviour (meaning the details are shown as normally, not an empty page).

mibfire’s picture

Component: watchdog.module » ajax system

Why is this issue closed? I can't look at the detail page because user doesn't exist.