I was working on http://drupal.org/node/81958 and found a bug with t(), specifically the array_walk() function.

With the patch working, when deleting users with PHP 4.4.2, it returns a blank screen or warning: array_walk(): Unable to call () - function does not exist in /Users/edmund/Documents/htdocs/cvs/drupal/includes/common.inc on line 636. Digging deeper leads to the t() in user_delete when returning feedback to admin for deleted users (watchdog and drupal_set_message).

Works alrite with PHP 5. Changing the placeholder from % to @ in the t()'s of user_delete makes the problem disapear.

Heine experienced the same problem, and chx pointed out http://bugs.php.net/bug.php?id=20658.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

edmund.kwok’s picture

To reproduce if you're running PHP 4:

1. Get latest HEAD and patch http://drupal.org/files/issues/delete_multiple_users_7.patch user.module
2. Add dummy users, skip this if you already have them
3. Start deleting users! (try selecting only one user to delete, or two users one after another, or two users both at different ends of the list, or just randomly select)
4. You'll know you hit the bug when you get a blank screen or the warning message instead of a delete successful message.

Admin logs might have some clues as to what's happening.

chx’s picture

I only linked that bug out to make my point that array_walk is very unlikely (but of course not impossible) to be the culprit as that's the only open array_walk crash bug and it's severl years old.

But, why the array_walk here? Is a mere php loop slower than iterating with array_walk which includes a function call?

Heine’s picture

FileSize
676 bytes

t() segfaults either gives the above warning or segfaults Apache (Apache/2.2.2 (Win32), php 4.4.2-pl) on certain pages. Last string & args before crash on user delete:

Deleted user: %name %email. 
Array
(
    [%name] => ddd
    [%email] => <D@adf>
)

Attached patch replaces array_walk with a loop. I haven't observed any crashes or array_walk errors since.

edmund.kwok’s picture

Tested patch and no more warnings or blank pages.

AjK’s picture

Patch in #3, applied and tested. Looks good.

regards,
--AjK

chx’s picture

Status: Active » Needs work

why the function call inside the loop? move the switch inside.

AjK’s picture

FileSize
990 bytes

chx, you mean like in the attached patch?

The comments for _t() refer to t() and st() but couldn't find st() in the API manual. If st() "is no more" then the helper function _t() could be removed.

regards,
--AjK

Heine’s picture

both _t and _st replaced with an inline foreach

AjK’s picture

Status: Needs work » Needs review

Patch in #8 applied and tested. Looks good.

regards,
--AjK

dww’s picture

Status: Needs review » Reviewed & tested by the community

i was having all sorts of evil problems trying to run update.php from 4.7 to 5.0 on my local test site and apache kept seg faulting or getting bus errors. after applying #8, all those problems went away, and i could finally update to 5.0. i reviewed the code and it looks fine to me. patch from #8 is hereby RTBC.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)