From 5280c2dec6b69d06e555d8118b769244301807d4 Mon Sep 17 00:00:00 2001 From: Mo McRoberts Date: Wed, 16 Nov 2016 09:41:22 +0000 Subject: [PATCH] Don't ever apply a trigger to the entity that's triggering the update (#94) --- twine/generate/triggers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/twine/generate/triggers.c b/twine/generate/triggers.c index 5e5fa9d..7be44a6 100644 --- a/twine/generate/triggers.c +++ b/twine/generate/triggers.c @@ -79,13 +79,18 @@ spindle_trigger_apply(SPINDLEENTRY *entry) { return 0; } - rs = sql_queryf(entry->generate->db, "SELECT \"id\", \"flags\" FROM \"triggers\" WHERE \"triggerid\" = %Q", entry->id); + rs = sql_queryf(entry->generate->db, "SELECT \"id\", \"flags\", \"triggerid\" FROM \"triggers\" WHERE \"triggerid\" = %Q", entry->id); if(!rs) { return -1; } for(; !sql_stmt_eof(rs); sql_stmt_next(rs)) { + /* Never apply a trigger to the entry itself */ + if(!strcmp(sql_stmt_str(rs, 0), sql_stmt_str(rs, 2))) + { + continue; + } flags = (int) sql_stmt_long(rs, 1); if(!flags) {