As a site admin in the View UI, if I add a field to the view that is a fivestar field, I get the following AJAX error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: http://example.com/admin/structure/views/ajax/add-item/news_latest/page/field
StatusText: OK
ResponseText: Fatal error: Unsupported operand types in /var/www/sites/all/modules/fivestar/includes/fivestar.field.inc on line 353
Call Stack:
3.4332     780280   1. {main}() /var/www/index.php:0
7.0341   14384288   2. menu_execute_active_handler(???, ???) /var/www/index.php:23
7.0412   14477400   3. call_user_func_array(???, ???) /var/www/includes/menu.inc:503
7.0412   14478400   4. views_ui_ajax_form(???, ???, ???, ???, ???) /var/www/includes/menu.inc:503
7.7039   16961248   5. views_ajax_form_wrapper(???, ???) /var/www/sites/all/modules/views/includes/admin.inc:2837
7.7039   16962552   6. drupal_build_form(???, ???) /var/www/sites/all/modules/views/includes/ajax.inc:218
7.7039   16966064   7. drupal_retrieve_form(???, ???) /var/www/includes/form.inc:317
7.7041   16967736   8. call_user_func_array(???, ???) /var/www/includes/form.inc:773
7.7041   16968352   9. views_ui_config_item_form(???, ???) /var/www/includes/form.inc:773
7.7537   17500096  10. views_handler_field_field->options_form(???, ???) /var/www/sites/all/modules/views/includes/admin.inc:4106
7.7683   17659840  11. fivestar_field_formatter_settings_form(???, ???, ???, ???, ???) /var/www/sites/all/modules/views/modules/field/views_handler_field_field.inc:397

XDEBUGGING the code prior to line 353 of the fivestar.field.inc:

<?php
  if ($instance['widget']['type'] == 'exposed') {  // line 349
    $entity_info = entity_get_info($instance['entity_type']);  // <-- this returns NULL
    // Include "Default" in the list of view modes to match the ones displayed
    // to the user; see field_ui_menu().
    $view_modes = array('default' => array('label' => t('Default'))) + $entity_info['view modes'];  // Line 353, fails because $entity_info is NULL
    $bundles = field_info_bundles($instance['entity_type']);

    $element['expose'] = array(
      '#type' => 'checkbox',
      '#title' => t('Expose this Fivestar field for voting in the @display display on the @type type.', array('@display' => $view_modes[$view_mode]['label'], '@type' => $bundles[$instance['bundle']]['label'])),
      '#default_value' => $settings['expose'],
      '#return_value' => 1
    );
  }
?>

Comments

jghyde’s picture

I am not sure what the func entity_get_info is supposed to provide. But ignoring it, and only adding the defaults, the widget seems to act fine. So, this may not be the final solution, but it gets me into the ballpark to complete my project:

<?php
// change the following, starting at line 349 on includes/fivestar.fields.inc
  if ($instance['widget']['type'] == 'exposed') {
    $entity_info = entity_get_info($instance['entity_type']);
    // Include "Default" in the list of view modes to match the ones displayed
    // to the user; see field_ui_menu().
    if (is_array($entity_info)) {
      $view_modes = array('default' => array('label' => t('Default'))) + $entity_info['view modes'];
    }
    else {
      $view_modes = array('default' => array('label' => t('Default')));
    }
    $bundles = field_info_bundles($instance['entity_type']);

    $element['expose'] = array(
      '#type' => 'checkbox',
      '#title' => t('Expose this Fivestar field for voting in the @display display on the @type type.', array('@display' => $view_modes[$view_mode]['label'], '@type' => $bundles[$instance['bundle']]['label'])),
      '#default_value' => $settings['expose'],
      '#return_value' => 1
    );
  }
?>
swfindlay’s picture

I'm having the same problem but neither of these patches work for me. The error message I get logged is classified under "Theme" and the content is: "MESSAGE Theme key "fivestar_widget" not found."

The implication (I think this is related) is that I get:

"Undefined property: stdClass::$subject in include()" and

"Trying to get property of non-object in block_block_view()"

in the blocks which use Fivestar. This may be because there is some of the widget still sitting in the database somewhere(?). But I'm not sure.

Can anyone help please?

Thanks

bensnyder’s picture

.........uuuuuurg.

Anyone have an older dev they can post?

ericduran’s picture

@swfindlay please try to keep the comments related to the issues. Sidetracking the issue isn't going to help anyone. Now regarding you error message please see #1268356: Theme key "fivestar_widget" not found. issue which I opened and fixed already.

@jghyde can you explain more regarding your views? I'm not really sure why entity_get_info is returning null, but I'm guessing the the fields instance settings might be missing. Maybe going in the node field settings and re-saving the field should fix it. Usually this happens when the field isn't completely saved with all the expected settings. Also please see issue #1224700: Remove custom views formatters regarding the issues with views.

ericduran’s picture

Status: Active » Closed (duplicate)
Canadaka’s picture

Status: Closed (duplicate) » Active

I just started having this problem as well after updating to the newest fivestar dev.

ericduran’s picture

Status: Active » Closed (duplicate)

@Canadaka, Please see my previous comments.

ericduran’s picture

Status: Closed (duplicate) » Fixed

Sorry for my stupidity :)

ericduran’s picture

@jghyde, Thanks for tracking it down. The entity info is honestly not needed and was there to help make the certain text more clearer to the user.

That being said this is now actually/properly fixed. At least to the best of my knowledge.

Please wait up to 12 hours for this commit to be packaged with the available .zip or tar files.

Thanks again.

Please see commit for more details : http://drupal.org/commitlog/commit/2490/b127837bcdb95e7db372bba9405eeff1...

Status: Fixed » Closed (fixed)

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

joachim’s picture

What does this mean:

"This is not saved to used here and is honestly not need it. "

Also, a t() replacement for the entity type was left behind -- see #1814070: mysterious text "Expose this Fivestar field for voting on the @type type. " in widget options.

Furthermore, code comments should not document code history:

> Removed entity_get_info here and simplified the text.