maicolacha22 / casetracker-for-drupal-7

Automatically exported from code.google.com/p/casetracker-for-drupal-7
0 stars 0 forks source link

Error on new case form #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new project.
2. Try to create a new case by going to the project and clicking on "add Case".

What is the expected output?
The add case form.

What do you see instead?

Error message

    Notice: Undefined index: render element in theme() (line 824 of /var/www/drupal/includes/theme.inc).
    Notice: Undefined property: stdClass::$nid in casetracker_project_options() (line 1113 of /var/www/drupal/sites/all/modules/casetracker/casetracker.module).
    Notice: Undefined property: stdClass::$nid in casetracker_project_options() (line 1113 of /var/www/drupal/sites/all/modules/casetracker/casetracker.module).

Fatal error: [] operator not supported for strings in 
/var/www/drupal/includes/theme.inc on line 1633 Call Stack: 0.0001 648136 1. 
{main}() /var/www/drupal/index.php:0 0.1597 35298928 2. 
menu_execute_active_handler() /var/www/drupal/index.php:25 0.4187 47748632 3. 
drupal_deliver_page() /var/www/drupal/includes/menu.inc:518 0.4188 47750000 4. 
drupal_deliver_html_page() /var/www/drupal/includes/common.inc:2437 0.4188 
47750912 5. drupal_render_page() /var/www/drupal/includes/common.inc:2542 
0.4226 47845864 6. drupal_render() /var/www/drupal/includes/common.inc:5510 
0.4226 47848848 7. theme() /var/www/drupal/includes/common.inc:5634 0.4447 
52327144 8. theme_render_template() /var/www/drupal/includes/theme.inc:937 
0.4450 53332592 9. include('/var/www/drupal/themes/seven/page.tpl.php') 
/var/www/drupal/includes/theme.inc:1247 0.4471 54229080 10. render() 
/var/www/drupal/themes/seven/page.tpl.php:29 0.4471 54229288 11. 
drupal_render() /var/www/drupal/includes/common.inc:5733 0.4471 54237072 12. 
drupal_render() /var/www/drupal/includes/common.inc:5641 0.4478 54275376 13. 
drupal_render() /var/www/drupal/includes/common.inc:5641 0.4479 54281632 14. 
theme() /var/www/drupal/includes/common.inc:5634 0.4817 54317184 15. 
theme_casetracker_case_form_common() /var/www/drupal/includes/theme.inc:894 
0.5428 55319720 16. theme() 
/var/www/drupal/sites/all/modules/casetracker/casetracker.module:961 0.5428 
55321224 17. theme_table() /var/www/drupal/includes/theme.inc:894 

Please use labels and text to provide additional information.
This is related to the function:

/**
 * API function that returns valid project options.
 */
function casetracker_project_options() {
  $projects = array();
  // Fetch the views list of projects, which is space-aware.
  if ($view = views_get_view(variable_get('casetracker_view_project_options', 'casetracker_project_options'))) {
    $view->set_display();
    $view->set_items_per_page(0);
    $view->execute();

    foreach ($view->result as $row) {
      $projects[$row->nid] = $row->node_title;
    }
  }
  return $projects;
}

The $view has no nid associated. But on this similar function:

/**
 * API function that returns valid user options.
 */
function casetracker_user_options() {
  $users = array();
  $options = array();
  if ($view = views_get_view(variable_get('casetracker_view_assignee_options', 'casetracker_assignee_options'))) {
    $view->set_display();
    $view->set_items_per_page(0);
    $view->execute();
    foreach ($view->result as $row) {
      $options[$row->uid] = $row->users_name;
    }
  }

  $anon_user = casetracker_default_assign_to();

  // fill in "Unassigned" value because view is not rendered and the redundant option in views is irrelevant
  // @TODO render the view before display so this isn't needed.
  if (isset($options[0])) {
    $options[0] = $anon_user;
  }
  // if "Unassigned" is the default assignee, we graft it onto the view results here as most views
  // that do any substantive filtering will exclude the anonymous user.
  elseif (in_array(variable_get('casetracker_default_assign_to', $anon_user),   array($anon_user, variable_get('anonymous', t('Anonymous'))))) {
    $options = array($anon_user) + $options;
  }
  return $options;
}

The $view has a uid.

Original issue reported on code.google.com by anthonyg...@gmail.com on 23 Oct 2011 at 12:33

Attachments:

GoogleCodeExporter commented 9 years ago
A ugly fix was used by adding a constant value:

...
foreach ($view->result as $row) {
  //$projects[$row->nid] = $row->node_title;
  $projects[1] = $row->node_title;
}
...

Now it's possible to create projects, but it must be "really" fixed later.

Original comment by anthonyg...@gmail.com on 14 Dec 2011 at 12:19