The "conditions" field in the notifications table is not updated when additional fields are added to a Custom Subscription.

To duplicate:

  • download notifications-6.x-4.0-beta7 & messaging-6.x-4.0-beta7
  • enable Custom Subscriptions, Content Notifications, Simple Mail, and dependencies.
  • create a new Custom subscription with Event type = node. Add a field (type=action, value=insert).
  • visit user/1/notifications and enable the new subscription.
  • revisit the Custom Subscriptions admin - add a second field to the subscription (type=node type, value=page)
  • You'll be notified that "1 subscriptions have been updated with the new values." .. however, this does not appear to be the case. Notifications will not be queued. The "conditions" field in the notifications table will still be "1". To get it to update to "2", you need to resubmit the form at user/1/notifications
  • Comments

    marinex’s picture

    Hi all, exists any solution?

    Update: YES - You must replace function in the notification_custom.admin.inc with this:

    /**
     * Update all fields for this subscription type
     */
    function notifications_custom_fields_update_all($subscription) {
      if ($count = db_result(db_query("SELECT COUNT(*) FROM {notifications} WHERE type = '%s'", $subscription->type))) {
        // Delete all fields for this subscription type
        db_query("DELETE FROM {notifications_fields} WHERE sid IN (SELECT sid FROM {notifications} WHERE type = '%s')", $subscription->type);
        // Create the new fields
        foreach ($subscription->get_fields() as $field) {
          db_query("INSERT INTO {notifications_fields} (sid, field, value, intval) SELECT sid, '%s', '%s', %d FROM {notifications} WHERE type = '%s'", $field->field, $field->value, (int)$field->value, $subscription->type);
        }
       //here is the solution whole the problem
        db_query("UPDATE {notifications} SET conditions = %d WHERE type = '%s'", count($subscription->get_fields()), $subscription->type);
        drupal_set_message(t('@count subscriptions have been updated with the new values.', array('@count' => $count)));
      }
    }
    

    Marinex

    Anonymous’s picture

    it worked perfectly, thanks a lot for your fix