http://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_lin... says "If element 'class' is included, it must be an array of one or more class names." sharethis_node_view() sets $links['sharethis']['attributes']['class'] to a string, not an array. This causes errors in theme_links() implementations that expect it to be an array.

Comments

swati.karande’s picture

Hi,
I am not getting this error on my local instance.
Can you tell me the steps to replicate it?

sreynen’s picture

You can see the error by running the module with this theme: http://drupal.org/sandbox/kenwoodworth/1250998

To be clear, I'm not suggesting the module needs to consider specific themes, only that it should follow the documentation, which says class must be an array.

Zarabadoo’s picture

Here is a patch to move things along.

Zarabadoo’s picture

Not to self: actually attach the patch.

ultimateboy’s picture

Status: Active » Needs review

Another note to yourself Al... set the status :D

sreynen’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me.

robloach’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xurubo93’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

I changed the status of this issue to active because it's still throwing errors. In the function sharethis_node_view($node, $view_mode, $langcode) the current code is:

  switch (variable_get('sharethis_location', 'content')) {
    case 'content':
      $enabled_types = $data_options['sharethis_node_types'];
      if (isset($enabled_types[$node->type]) && $enabled_types[$node->type] === $node->type) {
        $node->content['sharethis'] = array(
          '#tag' => 'div', // Wrap it in a div.
          '#type' => 'html_tag',
          '#attributes' => array('class' => 'sharethis-buttons'),
          '#value' => theme('sharethis', array('data_options' => $data_options, 'm_path' => $mPath, 'm_title' => $mTitle)),
          '#weight' => intval(variable_get('sharethis_weight', 10)),
        );
      }
    break;
    case 'links':
      $enabled_view_modes = variable_get('sharethis_' . $node->type . '_options', array());
      if (isset($enabled_view_modes[$view_mode]) && $enabled_view_modes[$view_mode]) {
        $links['sharethis'] = array(
          'html' => TRUE,
          'title' => theme('sharethis', array('data_options' => $data_options, 'm_path' => $mPath, 'm_title' => $mTitle)),
          'attributes' => array('class' => 'sharethis-buttons'),
        );
        $node->content['links']['sharethis'] = array(
          '#theme' => 'links',
          '#links' => $links,
          '#attributes' => array(
            'class' => array('links', 'inline'),
          ),
          '#tag' => 'div', // Wrap it in a div.
          '#type' => 'html_tag',
          '#weight' => intval(variable_get('sharethis_weight', 10)),
        );
       }
    break;
  }

Only in the $node->content['links']['sharethis'] - array the class is an array.

It should be:

  switch (variable_get('sharethis_location', 'content')) {
    case 'content':
      $enabled_types = $data_options['sharethis_node_types'];
      if (isset($enabled_types[$node->type]) && $enabled_types[$node->type] === $node->type) {
        $node->content['sharethis'] = array(
          '#tag' => 'div', // Wrap it in a div.
          '#type' => 'html_tag',
          '#attributes' => array('class' => array('sharethis-buttons')),
          '#value' => theme('sharethis', array('data_options' => $data_options, 'm_path' => $mPath, 'm_title' => $mTitle)),
          '#weight' => intval(variable_get('sharethis_weight', 10)),
        );
      }
    break;
    case 'links':
      $enabled_view_modes = variable_get('sharethis_' . $node->type . '_options', array());
      if (isset($enabled_view_modes[$view_mode]) && $enabled_view_modes[$view_mode]) {
        $links['sharethis'] = array(
          'html' => TRUE,
          'title' => theme('sharethis', array('data_options' => $data_options, 'm_path' => $mPath, 'm_title' => $mTitle)),
          'attributes' => array('class' => array('sharethis-buttons')),
        );
        $node->content['links']['sharethis'] = array(
          '#theme' => 'links',
          '#links' => $links,
          '#attributes' => array(
            'class' => array('links', 'inline'),
          ),
          '#tag' => 'div', // Wrap it in a div.
          '#type' => 'html_tag',
          '#weight' => intval(variable_get('sharethis_weight', 10)),
        );
       }
    break;
  }

anbarasan.r’s picture

StatusFileSize
new683 bytes

Attached the patch to solve the issue on the latest stable version 7.x-2.12.

anbarasan.r’s picture

Status: Active » Needs review

The last submitted patch, 4: sharethis-7.x-3.x-1957646-class-array.patch, failed testing.

anbarasan.r’s picture

Version: 7.x-2.x-dev » 7.x-2.12
ShareThis Support’s picture

Hi There,

Thanks for your patience here! We've made some changes in our support organization and we're working through responding to these. We've added this as a feature request for our team to review!

Best
ShareThis Support

purushotam.rai’s picture

  • purushotam.rai committed 3116b33 on 7.x-2.x
    Issue #1957646 by Zarabadoo, anbarasan.r, purushotam.rai: $links['...
purushotam.rai’s picture

Status: Needs review » Fixed

Issue is resolved with latest dev pushes.

Thanks all for your inputs.

Marking issue as fixed. Feel free to re-open if issue still persists

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.