| @@ -809,12 +809,26 @@ | ||
| 809 | 809 | if ( $provider->is_active() && '' !== $entry_language ) { |
| 810 | 810 | $provider->switch_language( $entry_language ); |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | + // Entries::add() has stored the logs collected so far. Start the instance | |
| 814 | + // empty so the update below writes only what send_email() records -- | |
| 815 | + // Entries::update() merges with the stored logs, so anything left here | |
| 816 | + // would be written twice. | |
| 817 | + $entries_db_instance = Entries::get_instance(); | |
| 818 | + $entries_db_instance->reset_logs(); | |
| 819 | + | |
| 813 | 820 | // Send email after entry creation so {entry_id} is available when smart tags are processed. |
| 814 | 821 | $send_email = $this->send_email( $id, $submission_data, $form_data ); |
| 815 | 822 | if ( $send_email ) { |
| 816 | 823 | $emails = $send_email['emails']; |
| 824 | + } | |
| 825 | + | |
| 826 | + // send_email() logs to the in-memory instance; the entry already exists, | |
| 827 | + // so the log only reaches it through an update. | |
| 828 | + $notification_logs = $entries_db_instance->get_logs(); | |
| 829 | + if ( ! empty( $notification_logs ) ) { | |
| 830 | + Entries::update( Helper::get_integer_value( $entry_id ), [ 'logs' => $notification_logs ] ); | |
| 817 | 831 | } |
| 818 | 832 | |
| 819 | 833 | $confirmation_message = Generate_Form_Markup::get_confirmation_markup( $form_data, $submission_data ); |
| 820 | 834 | $redirect_url = Generate_Form_Markup::get_redirect_url( $form_data, $submission_data ); |