From 4e5291c1dba11464e63c8b8358592eb2a1a5c081 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Wed, 23 Oct 2013 16:46:26 +0000
Subject: [PATCH] cdr_adaptive_odbc: Also apply a filter when the CDR value is
 empty.

Extra CDR records are written if a filtered CDR value is empty because the
filter is not checked.

(closes issue ASTERISK-22272)
Reported by: Jordi Llull Chavarria
........

Merged revisions 401577 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@401579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 cdr/cdr_adaptive_odbc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index 3f4c78654f..67dde10ff1 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -711,6 +711,14 @@ static int odbc_log(struct ast_cdr *cdr)
 					continue;
 				}
 				first = 0;
+			} else if (entry->filtervalue
+				&& ((!entry->negatefiltervalue && entry->filtervalue[0] != '\0')
+					|| (entry->negatefiltervalue && entry->filtervalue[0] == '\0'))) {
+				ast_verb(4, "CDR column '%s' was not set and does not match filter of"
+					" %s'%s'.  Cancelling this CDR.\n",
+					entry->cdrname, entry->negatefiltervalue ? "!" : "",
+					entry->filtervalue);
+				goto early_release;
 			}
 		}
 
-- 
GitLab