From 76a0471c291d2b8045b52ec8e9d683a38bff47ff Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 12 Oct 2012 04:04:14 -0400 Subject: Simplify the db_sql_live code since this isn't actually necessary. Fixes a problem internally ovwrwriting data on objects that we have modified and are queued because of assigning something to a serialize_obj reference --- modules/database/db_sql_live.cpp | 46 ++++++---------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'modules/database/db_sql_live.cpp') diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index 2aa3b73e6..9b683481b 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -74,7 +74,7 @@ class DBMySQL : public Module, public Pipe this->ro = false; this->init = false; - Implementation i[] = { I_OnReload, I_OnShutdown, I_OnLoadDatabase, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializePtrAssign, I_OnSerializeCheck, I_OnSerializableUpdate }; + Implementation i[] = { I_OnReload, I_OnShutdown, I_OnLoadDatabase, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializeCheck, I_OnSerializableUpdate }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); OnReload(); @@ -153,42 +153,6 @@ class DBMySQL : public Module, public Pipe s_type->objects.erase(obj->id); } - void OnSerializePtrAssign(Serializable *obj) anope_override - { - SerializeType *stype = obj->GetSerializableType(); - if (stype == NULL || !this->CheckInit() || stype->GetTimestamp() == Anope::CurTime) - return; - - if (obj->IsCached()) - return; - obj->UpdateCache(); - - SQLResult res = this->RunQueryResult("SELECT * FROM `" + this->prefix + stype->GetName() + "` WHERE `id` = " + stringify(obj->id)); - - if (res.Rows() == 0) - obj->destroy(); - else - { - const std::map &row = res.Row(0); - - if (res.Get(0, "timestamp").empty()) - { - obj->destroy(); - stype->objects.erase(obj->id); - } - else - { - Serialize::Data data; - - for (std::map::const_iterator it = row.begin(), it_end = row.end(); it != it_end; ++it) - data[it->first] << it->second; - - if (stype->Unserialize(obj, data) == NULL) - obj->destroy(); - } - } - } - void OnSerializeCheck(SerializeType *obj) anope_override { if (!this->CheckInit() || obj->GetTimestamp() == Anope::CurTime) @@ -241,8 +205,12 @@ class DBMySQL : public Module, public Pipe Serializable *new_s = obj->Unserialize(s, data); if (new_s) { - new_s->id = id; - obj->objects[id] = new_s; + // If s == new_s then s->id == new_s->id + if (s != new_s) + { + new_s->id = id; + obj->objects[id] = new_s; + } } else s->destroy(); -- cgit