I had some quick switch users in the settings then deleted them. Instead of an array, the variable 'masquerade_quick_switches' became '' and this caused an error in the foreeach at masquerade_block_1().
My fix is

Index: modules/masquerade/masquerade.module
===================================================================
--- modules/masquerade/masquerade.module	(revision 19104)
+++ modules/masquerade/masquerade.module	(working copy)
@@ -441,6 +441,7 @@
 
     // Add in user-specific switches.
     $result = db_query("SELECT uid_to FROM {masquerade_users} WHERE uid_from = %d", $user->uid);
+    $masquerade_switches = array();
     while ($uid_to = db_result($result)) {
       $masquerade_switches[] = $uid_to;
     }

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathan_hunt’s picture

Doh, that was bogus. Try

+  $quick_switch_users = (array)variable_get('masquerade_quick_switches', array());
+  foreach (($quick_switch_users) as $uid) {
     $u = user_load(array('uid' => $uid));
     if ($uid == 0) {
       $u->name = variable_get('anonymous', t('Anonymous'));
andypost’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Priority: Normal » Critical
Status: Active » Needs review
FileSize
2.81 KB

This is a critical because functionality broken.

Confirm this bug! This caused by running system_settings_form_submit() and saving wrong values before module submit function

Also fixed:
- menu rebuild called only if "menu quick switch" changed
- no reason to clear cache for blocks once system_settings_form_submit() clears both page and block cache

if we wanna to clear only cache_block so form need unset system_settings_form_submit handler and save all variables itself

andypost’s picture

values for 'masquerade_quick_switches' variable are prepared in _masquerade_admin_settings_validate() so system_settings_form_submit() now save valid values

masquerade_admin_settings_submit() now rebuilds menu if needed

afreeman’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, tests correctly in my environment.

deekayen’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to DRUPAL-6 branch.

andypost’s picture

Status: Patch (to be ported) » Closed (fixed)