There's a bit of discussion on the Writing actions handbook page. The code presented there is actually out of sync now with http://api.drupal.org/api/function/user_block_user_action.

The problem is that $user->name will only be set if we are working with the global $user. Otherwise the watchdog message will just be Blocked user .

This affects 7.x and 6.x.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gpk’s picture

Avivatech’s picture

i am new here....!

matason’s picture

Status: Active » Needs review
FileSize
1.04 KB

I've attached a small patch which should fix this.

Status: Needs review » Needs work

The last submitted patch failed testing.

matason’s picture

I'm not sure why this is failing now, the patch still runs against a freshly checked out HEAD, will investigate some more.

matason’s picture

Status: Needs work » Needs review
FileSize
1.04 KB

I've recreated the patch and tested it, seems to work okay.

Status: Needs review » Needs work

The last submitted patch failed testing.

entendu’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs work » Needs review
FileSize
537 bytes

Drupal 6 backport attached

entendu’s picture

FileSize
620 bytes

Oops, rerolled the D6 patch with #330090 in mind. Disregard last one.

ohnobinki’s picture

#3: user_block_user_action.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, user.module.patch, failed testing.

ohnobinki’s picture

It looks like this is fixed by the following change in drupal-7 for #721086: Create tests for system actions, clean up token replacement, clean up triggers:

--- modules/user/user.module
+++ modules/user/user.module
@@ -3401,3 +3403,4 @@
   drupal_session_destroy_uid($uid);
-  watchdog('action', 'Blocked user %name.', array('%name' => $user->name));
+  $account = user_load($uid);
+  watchdog('action', 'Blocked user %name.', array('%name' => $account->name));
 }

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.