I am testing my product checkout with Ubercart, and after the order is submitted, I get the attached error messages complaining about my profiles for services I'm not using (I'm only using Facebook and Twitter).

I get a bunch of these messages:

Notice: Undefined index: widgets in socialmedia_tokens() (line 133 of /var/www/brc/sites/all/modules/socialmedia/socialmedia.tokens.inc).
Notice: Undefined index: widgets in socialmedia_tokens() (line 133 of /var/www/brc/sites/all/modules/socialmedia/socialmedia.tokens.inc).

along with a bunch of these:

You are trying to use a social media Flickr profile token but the profile has not been set. Set Flickr profile.
You are trying to use a social media Flickr profile token but the profile has not been set. Set Flickr profile.
You are trying to use a social media Google+ profile token but the profile has not been set. Set Google+ profile.
You are trying to use a social media Google+ profile token but the profile has not been set. Set Google+ profile.

I'm not using Google+, Flickr, and others (just FB and Twitter).

CommentFileSizeAuthor
#19 fix.PNG75.42 KBlivlogik
#18 error.png325.29 KBlivlogik
sm_2.png230.6 KBvintorg
sm_1.png270.31 KBvintorg
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Demoshane’s picture

Yes, same for me. Maybe it is related somehow to ubercart? Its bit tricky as I need to show error messages to customers and this pops out every time someone places order, then customer calls to our customer service and asks if he's payment has arrived or not or are his bank details safe etc. I did temporary fix and disabled messages with css from order completition page.

nyleve101’s picture

Hi,

I'm also having this problem, did anyone manage to resolve it?

Hope all is well,

EVelyn

vosindia’s picture

Hey Guys,

Its Very simple

Go to Home » Administration » Configuration » Media » Social media

then enter all the social media link and password to profile Tab, all error message will gone

aniebel’s picture

@vosindia, suppose you only want to display Facebook and Twitter. Not everyone wants to show every single social media link.

rudymg24674’s picture

There's another thread in this forums outlining the same problem. And I agree with Aniebel - not every company is going to possibly have login credentials for every single social media profile, in fact I highly doubt many people actually do use every single one listed in this module. For whatever reason, when we "uncheck" the boxes for the profiles we do not want to use for the site, ubercart is still somehow calling those tokens after checkout. I can only imagine that there is some sort of naming problem between the two modules, and whatever Ubercart does after checkout on the order confirmation page, is somehow calling the tokens for the social media module.

rudymg24674’s picture

does anyone have any idea on how we can start tackling this problem?? right now I'm using CSS to hide the error message, but that's obviously not the right way to go about doing this. I'm just about ready to pay someone to fix this problem, because overall I like the social media module - it's just this one conflict with ubercart checkout...

So if someone with more experience with module writing can lend a hand, let's see if we can crack this one...

vintorg’s picture

I can't believe this hasn't been touched.

aniebel’s picture

An easy way to handle it is to turn off Configuration>Development>Logging & Errors but that would prevent you from seeing any others.

rudymg24674’s picture

yeah that's not really a solution - that's just like what I'm doing now, by using CSS to hide the error message... which isn't good because there are actual error messages that I do want them to see.

I don't know much about debuggin, and what not. I wish there was some program/plugin that I could run, so I could see every action and call that goes on during the checkout process. I know the answer is there, and I'm almost certain it's a similar naming issue...

rudymg24674’s picture

I asked for some help in the Ubercart forums - and this is the response that I got

First of all, there is absolutely, positively, a bug in the Social Media module that is causing this. Here's the code from http://drupalcode.org/project/socialmedia.git/blob/refs/heads/7.x-1.x:/s...

_socialmedia_widgets_set_error($data['widgets']['element'], $msg);

This code expects the "$data" array to have a 'widgets' element, and it doesn't. There is no sanity check to make sure it's there, so there's a "Notice".

Now, why is this happening in the middle of Ubercart code? That's probably a Drupal hook doing that.

Hooks allow modules to declare code that should be executed every time "something" happens. Fon instance, you can have a module execute a bit of code every time a new page (node) is created.

So, Ubercart is engaging in some activity, probably doing Drupal stuff, that triggers a hook in your social media module. The hook code in the social media module is buggy, and it's giving the index errors.

Looking at /var/www/brc/sites/all/modules/socialmedia/socialmedia.tokens.inc, the error is in the socialmedia_tokens function call. This probably relates to Drupal tokens, as described at http://drupal.org/project/token.

Tokens are bits of text that work like variables. For instance, you can put "[site:url]" in a message to users, and Drupal will substitute the URL of your site. Ubercart, including its checkout page uses tokens. For instance, [uc_order:payment-balance] give you the customer's current balance.

So, both Ubercart and Social Media use tokens. Ubercart is obviously doing something with tokens hard enough that it provokes errors in the Social Media module. From what I've seen, it probably goes through all of the tokens in some loop, whether or not they're activated.

Frankly, the best way to solve this is to attach some sort of PHP debugger to the system and make it output a full backtrace when it hits that line. That will show you exactly where in Ubercart the error is triggered. I'm not a PHP expert, so I don't know how to do that, but lots of people are. Obviously, it's going to be in the order confirmation screen

A review of the code shows that this bug is inside of some error handling code. You were supposed to get THIS error message:

"You are trying to use a social media %platform profile token but the profile has not been set. !link"

So, it looks like Ubercart is trying to do something with all the tokens. In fact, if you look at admin/store/settings/checkout, there is a list of all the possible tokens, for your convenience. Perhaps when Ubercart tries to list them, it sets off this error.

Good luck, and don't let anyone tell you this is your fault. It's absolutely a bug in the Social Media module. Ubercart might be provoking it, but the root is not in Ubercart.

Off the top of my head, the fix for this is to set something in the Social Media module that removes the tokens from global use when the profiles are deactivated.

Thoughts anyone??

rudymg24674’s picture

I posted this in the Ubercart forums to see if anyone with Devel experience on Ubercart can see the problem.

http://pastebin.com/k9F2peQb

I installed Devel - and ran through the checkout process again - down on line 479 of the pastebin - you will see that there are calls to load social media profiles, and it goes through all of them... This is the problem, clearly, I just don't know where/what is invoking this, or how to drill down to see it...

anyone with experience have any idea how I can pinpoint where/how this is being called?? All of the stuff on the top of the pastebin are expandable menues so if someone needs me to dig deeper into it I can.

rudymg24674’s picture

or is the other option for now, to just remove this "notice"?? until something gets fixed here??

if (!isset($replacement) || $replacement === FALSE) {
			    $msg = t('You are trying to use a social media %platform profile token but the profile has not been set. !link',
			      array(
			        '%platform' => $platform['title'],
			        '!link' => l(t('Set @platform profile.', array('@platform' => $platform['title'])), 'admin/config/media/socialmedia')
			      )
			    );
			    _socialmedia_widgets_set_error($data['widgets']['element'], $msg);
        }
        else {
        	$replacements[$original] = $replacement;
        }
rudymg24674’s picture

I commented out

 $msg = t('You are trying to use a social media %platform profile token but the profile has not been set. !link',
			      array(
			        '%platform' => $platform['title'],
			        '!link' => l(t('Set @platform profile.', array('@platform' => $platform['title'])), 'admin/config/media/socialmedia')
			      )
			    );
			    _socialmedia_widgets_set_error($data['widgets']['element'], $msg);
        }

and left everything else there - the entire if/else statement - doesn't resolve the underlying problem, but it's removed the messages from showing up... a workaround for now until I either find a new module, or someone decides to start maintaining this module again... and if not it really needs to have its status changed...

vintorg’s picture

Yeah, it's totally on the social media side.

Dan Z’s picture

You know, instead of commenting out that whole mess, you might perhaps just replace it with

if (!isset($replacement) || $replacement === FALSE) {
  $replacements[$original] = $original;
 } else {
   $replacements[$original] = $replacement;
 }

That way, if it got some unusable token for some unregistered site, the text would just be replaced with...itself. It would make sure the array got properly populated, too. This could avoid possible errors down the line.

It's an ugly hack, of course. It might create an infinitely recursive loop that would implode into a black hole that would suck in the entire solar system in a microsecond...or it might solve your problem neatly. Give it a try and see what happens.

Oh, and if you're having other errors after doing this, make sure to uninstall this module and see if the errors persist.

rudymg24674’s picture

haha - Z-twist, I'll have to see how that manages.

See the problem is, I'm still fairly new at Drupal - I'm an extremely fast learner though - but from what I've been gathering, this module wasn't written properly with best practices. But it has so much potential... it's just a shame it's no longer being maintained.

It almost felt like an advertisement from Level Ten.

I'll have to give your suggestion a try - and in the mean time, I'm going to learn a bit about module development, and see if I can't determine the ACTUAL problem with this module.

TomDude48’s picture

If someone who is using Social media with Ubercart would like to submit a patch I would be happy to review it.

In the meantime, try removing the superfluous widgets from your widget sets. See http://drupal.org/node/1599114#comment-6279354 for direction.

livlogik’s picture

FileSize
325.29 KB

has anyone found a fix for this? i keep getting this error everytime someone submits a order--->

"Notice: Undefined index: widgets in socialmedia_tokens() (line 144 of /home/content/50/9927750/html/sites/all/modules/socialmedia/socialmedia.tokens.inc)."

here is a SS attached.

Thanks :D

livlogik’s picture

FileSize
75.42 KB

Hey guys! i just wanted to let you know i go a fix for this.

I have a screenshot attached but here is what i did.

  • admin >> config >> media >> social share
  • click on the set up wizard.
  • now with all the social profiles you have to enter the ones you dont have or dont use put what i have in the screen shot (put the default url like http://www.twitter.com and put test in the username box) and of course what you do use put your info.
  • click save profiles
  • then check the icons that you want people to see and click save profile widget buttons
  • then check the icons that you want people to see of the share icons and then click save share widget buttons.
  • then select the regions that you want all the widgets in and then click save
  • Then your all done :D

i hope this was helpful please let me know if it works for everyone else.

-LivLogik

earthangelconsulting’s picture

Issue summary: View changes

i found out a solution before i even found this thread, and here it is:

1) make sure that JUST THE WIDGETS YOU ARE USING have usernames and URLs filled in, as in #19 above, doesn't have to be the ones you aren't using at all.

2) if you aren't using the 'user' and 'site' versions of the tokens provided by this module, just disable them entirely. I did this by commenting out a few lines in socialmedia.tokens.inc (basically anything that refers to $tokens['site'] or $tokens['user']).

Why is this related to Ubercart? because Ubercart order generation does something non-standard (but not generally harmful) with tokens: in function template_preprocess_uc_order (the theme preprocess for template uc-order--customer.tpl), all tokens in groups 'site' and 'user' are evaluated ahead of time, so that they can be presented as variables for use within the template (as opposed to running the template result through the token substituter afterwards). and something about how it evaluates the social media subset of 'site' or 'user' is just wonky. it's possible it might not even work properly even if Ubercart was using tokens normally, that i am not sure of.

ONE of these modules might have done something that wasn't best-practice regarding how to properly implement a subset of a token group, and without further digging, I am not going to go out on a limb and say which module it was :-)

anyhow, if you get those lines out of the socialmedia module then all will be well, and you can still use the tokens from set 'socialmedia' if you want.

though really (hint to maintainer, if you are listening?), you should be able to entirely disable the tokens provided by this module, that's just extra overhead if you aren't using them.