From 446b3a910d457ce32e6accd4ecc47e6e02f66ed4 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 24 Aug 2013 22:23:04 -0400 Subject: [PATCH] Save unconfirmed status and passcodes in the database. Fix db_sql_live to not reinsert all records if there are extra columns. Plexus has no chmode +r --- modules/commands/ns_register.cpp | 4 ++-- modules/database/db_sql.cpp | 10 ++++++---- modules/database/db_sql_live.cpp | 10 ++++++---- modules/protocol/plexus.cpp | 1 - 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index abe3d314b..a1c1e7f47 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -340,8 +340,8 @@ class NSRegister : public Module CommandNSConfirm commandnsconfirm; CommandNSResend commandnsrsend; - PrimitiveExtensibleItem unconfirmed; - PrimitiveExtensibleItem passcode; + SerializableExtensibleItem unconfirmed; + SerializableExtensibleItem passcode; public: NSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index f6af798b4..6add33f93 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -243,11 +243,13 @@ class DBSQL : public Module, public Pipe if (obj) { + /* The Unserialize operation is destructive so rebuild the data for UpdateCache. + * Also the old data may contain columns that we don't use, so we reserialize the + * object to know for sure our cache is consistent + */ + Data data2; - /* The Unserialize operation is destructive so rebuild the data for UpdateCache */ - for (std::map::const_iterator rit = row.begin(), rit_end = row.end(); rit != rit_end; ++rit) - if (rit->first != "id" && rit->first != "timestamp") - data2[rit->first] << rit->second; + obj->Serialize(data2); obj->UpdateCache(data2); /* We know this is the most up to date copy */ } } diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index 7ef0528a8..f74933b98 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -216,11 +216,13 @@ class DBMySQL : public Module, public Pipe new_s->id = id; obj->objects[id] = new_s; + /* The Unserialize operation is destructive so rebuild the data for UpdateCache. + * Also the old data may contain columns that we don't use, so we reserialize the + * object to know for sure our cache is consistent + */ + Data data2; - /* The Unserialize operation is destructive so rebuild the data for UpdateCache */ - for (std::map::const_iterator rit = row.begin(), rit_end = row.end(); rit != rit_end; ++rit) - if (rit->first != "id" && rit->first != "timestamp") - data2[rit->first] << rit->second; + new_s->Serialize(data2); new_s->UpdateCache(data2); /* We know this is the most up to date copy */ } } diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 6a2b65794..37516d928 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -369,7 +369,6 @@ class ProtoPlexus : public Module ModeManager::AddChannelMode(new ChannelMode("NOEXTERNAL", 'n')); ModeManager::AddChannelMode(new ChannelMode("NONOTICE", 'N')); ModeManager::AddChannelMode(new ChannelMode("PRIVATE", 'p')); - ModeManager::AddChannelMode(new ChannelModeNoone("REGISTERED", 'r')); ModeManager::AddChannelMode(new ChannelMode("SECRET", 's')); ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't')); ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O'));