I am experiencing an error when creating some nodes of a particular content type on my site: It triggers a 500 error when users try to save the node. When I look into the log error this is the message displayed:

Notice: Trying to get property of non-object in _MO_events_is_event_page() (line 461 of /var/www/Server_Name/htdocs/MO/sites/all/modules/features/MO_events/MO_events.module).

Does anyone have any ideas as to what may be the cause?

Here is the Code on line 461

function _MO_events_is_event_page() {
  $is_event = &drupal_static(__FUNCTION__);

  if (NULL === $is_event) {
    $menu_item = menu_get_item();
// If the current menu router is a node of type event or virtual_conference we're on an event page

     //Line 461:  
    $is_event = (TRUE === isset($menu_item['page_arguments'][0]) && TRUE === isset($menu_item['page_arguments'][0]->type) && ('event' == $menu_item['page_arguments'][0]->type) || 'virtual_conference' == $menu_item['page_arguments'][0]->type);

          return $is_event;
  • Looks like someone has added some custom code to a Features module, and given that there's potentially more than 461 lines of code to be examined the solution may not be easy to elicit on this forum. Have you got a developer who knows the site? Apr 9 '13 at 15:58
  • The only way to know what happens is debugging the code. Considering there could be some custom code involved in the error, it is rather impossible for anybody who doesn't see the code to be able to say what is causing the error. Maybe somebody had a similar case, and could say what they did, but there is a chance that doesn't help you.
    – apaderno
    Apr 9 '13 at 16:03
  • There is no custom code involved the MO_events module was generated by the features module for export from dev server to production server i was hoping some one might have experienced the same and had a solution Apr 9 '13 at 16:11
  • I would call the code generated from a module custom code, especially when the generated code depends from settings or options. This is a question about code, where the involved code is not shown. If you report the settings/options used when generating the module, then somebody who has more experience with the Feature module could point out what happens.
    – apaderno
    Apr 9 '13 at 16:16
  • i have add the code from the function at line 461 if this helps Apr 9 '13 at 16:23

That error means that $menu_item['page_arguments'][0] isn't an object in the context in which that code is run. It's probably happening during a redirect where the page isn't node/123, and so there's no node object available.

You can fix it by adding a bit of error checking (I've taken the liberty of using menu_get_object() instead of menu_get_item(), it's a more standard way of getting the current node object):

function _MO_events_is_event_page() {
  $is_event = &drupal_static(__FUNCTION__);

  if ($is_event === NULL && $node = menu_get_object()) {
    $is_event = $node->type == 'event' || $node->type == 'virtual_conference';

  return (bool) $is_event;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.