When using hook_nodeapi() to call rsvp_api_create_invitation() the $node object lacks a title, which causes an error when you try to include the title in drupal_set_message() and watchdog().

I ran into this coding a module to automatically create invitations for newly inserted nodes.

I've attached a patch that assumes silent invitation creation when the $node object isn't populated yet, avoiding setting messages when there's no node object yet.

CommentFileSizeAuthor
rsvp.api-messages_bug.patch990 bytesdreamdust
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dreamdust’s picture

Version: 6.x-2.0-rc4 » 6.x-2.0

Oops I selected wrong version. This is 6.x-2.0

DamienMcKenna’s picture

Why are you checking against $node->title, the watchdog() and drupal_set_message() lines don't use it? It would make more sense to do this:

          if ($rsvp != FALSE) {
            drupal_set_message(t('New invitation %rsvp_name(%rid) has been created successfully.'), array('%rsvp_name' => $rsvp->name, '%rid' => $rid));
            if (!empty($node->nid)) {
              watchdog('action', 'Successfully created invitation %rsvp_name(%rid) for node %nid.', array('%rsvp_name' => $rsvp->name, '%rid' => $rid, '%nid' => $node->nid));
            }
          }