I just started receiving an error message on my social media widget.

* Notice: Undefined property: stdClass::$data in _socialmedia_widgets_get_facebook_locales() (line 609 of C:\xampp\htdocs\drupal_test\sites\all\modules\socialmedia\socialmedia.widgets.inc).
* Notice: Trying to get property of non-object in _socialmedia_widgets_get_facebook_locales() (line 610 of C:\xampp\htdocs\drupal_test\sites\all\modules\socialmedia\socialmedia.widgets.inc).
* Warning: Invalid argument supplied for foreach() in _socialmedia_widgets_get_facebook_locales() (line 610 of C:\xampp\htdocs\drupal_test\sites\all\modules\socialmedia\socialmedia.widgets.inc).

Please let me know what further information I can provide to help resolve this.

I searched but did not see any reference to those errors anywhere.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Delty’s picture

Same...

seisunos’s picture

This error occurs only when cache is cleared.

I solved this problem with the help of Devel Module. If you go to the code line typed in the message, you insert a Devel debug instruction (dpm($result);), under the request sentence ($result = drupal_http_request("https://www.facebook.com/translations/FacebookLocales.xml");), and you clear the cache, you'll see the detailed error: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?

Then, you can enable that extension in your php.ini (extension=php_openssl.dll).

Hope this helps.

alblez’s picture

I have a similar error
Error opening socket ssl://www.facebook.com:443
but I believe take active openssl
my phpinfo():

openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.1e 11 Feb 2013
OpenSSL Header Version OpenSSL 1.0.1e 11 Feb 2013

this occurs in a development server, I hope that when I go to production not have problems

seisunos thanks for the tip to debug

eletomm’s picture

Issue summary: View changes

Sorry to reopen this one..but I have this error and I have tried all step that I found on all issues...can anybody tell me how to solve the problem?

cserna’s picture

Hi!
Solution at #2 worked for me. Thanks!

kenorb’s picture

Version: 7.x-1.0-beta13 » 7.x-1.0-beta15
$ drush -y cc all
Invalid argument supplied for foreach() socialmedia.widgets.inc:754

OpenSSL is present.

Affected line:

foreach ($xml->locale as $line) {

Context:

function _socialmedia_widgets_get_facebook_locales() {
  $fb_locale = array();
  $cache = cache_get('socialmedia_facebook_locales');
  if (empty($cache->data)) {
    $result = drupal_http_request("https://www.facebook.com/translations/FacebookLocales.xml");
    $xml = simplexml_load_string($result->data);
    foreach ($xml->locale as $line) {

Testing:

$ drush ev 'print_r(drupal_http_request("https://www.facebook.com/translations/FacebookLocales.xml"));'
stdClass Object
(
    [code] => 0
    [error] => Error opening socket ssl://www.facebook.com:443

$ curl -s https://www.facebook.com/translations/FacebookLocales.xml | head
<?xml version='1.0'?>
<locales>
<locale>
<englishName>Afrikaans</englishName>

Sometimes it can be related to transparent corporate proxy so some certificates needs to be imported, or firewall (which blocks Facebook).

But in this case, curl works, so it's something else.

So still code needs to implement some failing scenario when the host is not reachable.

larskleiner’s picture

The attached patch checks if there are no errors in the response from Facebook before trying to cache the locale. It won't fix any issues with the call to Facebook but it will suppress the Undefined property related notices and warnings.

kenorb’s picture

Status: Active » Needs review
kyletaylored’s picture

Status: Needs review » Closed (duplicate)

This was fixed in a recent issue.

#2556779: Facebook Locales XML feed broken

While just checking for the data works, I'm going to assume it isn't coming back. There was a JSON version on Github that I linked to to use that as well, so at least there is some sort of fallback available.