Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I've got widgets and socialmedia installed on my website and when I clear the cache I get an "illegal offset type" warning through all the _widgets_errors() function, on lines 1024, 1028 and 1033(everywhere there's a $errors[$name] basically).
This is due to the fact that at some point the $name variables contains an array, as you can see from its dump:
string 'socialmedia_socialmedia-twitter-share-button-custom' (length=51)
array (size=12)
'platform' => string 'facebook' (length=8)
'label' => string 'Socialmedia Facebook share button' (length=33)
'group' => string 'Social media: Facebook' (length=22)
'template' => string '<a href="http://www.facebook.com/sharer.php?u=[|[node:url]||[current-page:url]|]&t=[|[node:title]||[current-page:title-plain]|]" title="Visit [?profile_username=[socialmedia:sm-facebook_username]?] on Facebook"[?link-target= target="{[socialmedia:sm-default_link_target_sharing]}"?][?link-rel= rel="{[socialmedia:sm-default_link_rel_sharing]}"?]><img src="[?icon-path=[socialmedia:sm-facebook_icon-path]?]" alt="Facebook icon" ></a>' (length=432)
'form callback' => string 'socialmedia_widgets_share_platforms_form' (length=40)
'module' => string 'socialmedia' (length=11)
'name' => string 'socialmedia_socialmedia-facebook-share-button' (length=45)
'data' =>
array (size=0)
empty
'storage' => int 4
'weid' => string '10' (length=2)
'wsid' => string '2' (length=1)
'weight' => string '-7' (length=2)
array (size=12)
'platform' => string 'facebook' (length=8)
'label' => string 'Socialmedia Facebook share button' (length=33)
'group' => string 'Social media: Facebook' (length=22)
'template' => string '<a href="http://www.facebook.com/sharer.php?u=[|[node:url]||[current-page:url]|]&t=[|[node:title]||[current-page:title-plain]|]" title="Visit [?profile_username=[socialmedia:sm-facebook_username]?] on Facebook"[?link-target= target="{[socialmedia:sm-default_link_target_sharing]}"?][?link-rel= rel="{[socialmedia:sm-default_link_rel_sharing]}"?]><img src="[?icon-path=[socialmedia:sm-facebook_icon-path]?]" alt="Facebook icon" ></a>' (length=432)
'form callback' => string 'socialmedia_widgets_share_platforms_form' (length=40)
'module' => string 'socialmedia' (length=11)
'name' => string 'socialmedia_socialmedia-facebook-share-button' (length=45)
'data' =>
array (size=0)
empty
'storage' => int 4
'weid' => string '10' (length=2)
'wsid' => string '2' (length=1)
'weight' => string '-7' (length=2)
string 'socialmedia_socialmedia-facebook-share-button' (length=45)
string 'socialmedia_socialmedia-google-share-button' (length=43)
string 'socialmedia_socialmedia-stumbleupon-share-button' (length=48)
string 'socialmedia_socialmedia-delicious-share-button' (length=46)
string 'socialmedia_socialmedia-digg-share-button' (length=41)
string 'socialmedia_socialmedia-linkedin-share-button' (length=45)
string 'socialmedia_socialmedia-myspace-share-button' (length=44)
string 'socialmedia_socialmedia-newsvine-share-button' (length=45)
string 'socialmedia_socialmedia-reddit-share-button' (length=43)
string 'socialmedia_socialmedia-technorati-share-button' (length=47)
string 'socialmedia_socialmedia-yahoo-share-button' (length=42)
string 'socialmedia_addthis-email' (length=25)
So the quick and dirty solution would be to check if $name is a string, but I don't think we can call it a good solution:
function _widgets_error($name, $action = 'get') {
if (!is_string($name)) {
return FALSE;
}
static $errors = array();
// TODO not sure if this is the best idea, but cures the symptoms of #1468030
if (!isset($errors[$name])) {
return FALSE;
}
if ($action == 'set') {
$errors[$name] = TRUE;
}
elseif ($action == 'reset') {
$errors[$name] = FALSE;
}
if (isset($errors[$name])) {
return $errors[$name];
}
else {
return FALSE;
}
}
Thank you for your attention
Comments
Comment #1
jinky32 CreditAttribution: jinky32 commentedHi,
I have the same issue which I think is the cause of the issue I've described http://drupal.org/node/1794398. Tweet button doesn't render in Chrome and no warning is shown however it doe appear in Firefox and a warning
Warning: Illegal offset type in isset or empty in _widgets_error() (line 1024 of /opt/drupal/sites/test.uk.d7test5/modules/widgets/widgets.module). shows
Comment #2
shabam CreditAttribution: shabam commentedI get a similar set of warnings:
I found this in Social Media: http://drupal.org/node/1468030
If you are running social media as well, that is likely the culprit. There is a patch available.