1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 03:06:38 +02:00

Rename Serializable::id to object_id to avoid conflicts.

This commit is contained in:
Sadie Powell
2025-12-19 17:44:19 +00:00
parent 93e5b871e1
commit 0ae67cb371
9 changed files with 41 additions and 41 deletions
+1 -1
View File
@@ -197,7 +197,7 @@ namespace SQL
virtual std::vector<Query> CreateTable(const Anope::string &table, const Data &data) = 0;
virtual Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) = 0;
virtual Query BuildInsert(const Anope::string &table, Serializable::Id id, Data &data) = 0;
virtual Query GetTables(const Anope::string &prefix) = 0;
+1 -1
View File
@@ -118,7 +118,7 @@ public:
virtual ~Serializable();
/* Unique ID (per type, not globally) for this object */
Id id = 0;
Id object_id = 0;
/* Only used by redis, to ignore updates */
unsigned short redis_ignore = 0;
+1 -1
View File
@@ -118,7 +118,7 @@ public:
Serializable *obj = stype->Unserialize(NULL, ld);
if (obj != NULL)
obj->id = ld.id;
obj->object_id = ld.id;
ld.Reset();
}
}
+2 -2
View File
@@ -43,8 +43,8 @@ public:
// Used when writing data.
Data(Serialize::Type *s_type, Serializable *obj)
{
if (obj->id)
this->id = obj->id;
if (obj->object_id)
this->id = obj->object_id;
s_type->Serialize(obj, *this);
}
+16 -16
View File
@@ -146,7 +146,7 @@ public:
Serialize::Type *t = obj->GetSerializableType();
/* If there is no id yet for this object, get one */
if (!obj->id)
if (!obj->object_id)
redis->SendCommand(new IDInterface(this, obj), "INCR id:" + t->GetName());
else
{
@@ -160,10 +160,10 @@ public:
std::vector<Anope::string> args;
args.emplace_back("HGETALL");
args.push_back("hash:" + t->GetName() + ":" + Anope::ToString(obj->id));
args.push_back("hash:" + t->GetName() + ":" + Anope::ToString(obj->object_id));
/* Get object attrs to clear before updating */
redis->SendCommand(new Updater(this, t->GetName(), obj->id), args);
redis->SendCommand(new Updater(this, t->GetName(), obj->object_id), args);
}
}
@@ -246,13 +246,13 @@ public:
std::vector<Anope::string> args;
args.emplace_back("HGETALL");
args.push_back("hash:" + t->GetName() + ":" + Anope::ToString(obj->id));
args.push_back("hash:" + t->GetName() + ":" + Anope::ToString(obj->object_id));
/* Get all of the attributes for this object */
redis->SendCommand(new Deleter(this, t->GetName(), obj->id), args);
redis->SendCommand(new Deleter(this, t->GetName(), obj->object_id), args);
this->updated_items.erase(obj);
t->objects.erase(obj->id);
t->objects.erase(obj->object_id);
this->Notify();
}
@@ -315,7 +315,7 @@ void ObjectLoader::OnResult(const Reply &r)
obj = st->Unserialize(obj, data);
if (obj)
{
obj->id = this->id;
obj->object_id = this->id;
obj->UpdateCache(data);
}
@@ -333,9 +333,9 @@ void IDInterface::OnResult(const Reply &r)
Serializable *&obj = o->GetSerializableType()->objects[r.i];
if (obj)
/* This shouldn't be possible */
obj->id = 0;
obj->object_id = 0;
o->id = r.i;
o->object_id = r.i;
obj = o;
/* Now that we have the id, insert this object for real */
@@ -431,12 +431,12 @@ void Updater::OnResult(const Reply &r)
std::vector<Anope::string> args;
args.emplace_back("SADD");
args.push_back("ids:" + this->type);
args.push_back(Anope::ToString(obj->id));
args.push_back(Anope::ToString(obj->object_id));
me->redis->SendCommand(NULL, args);
args.clear();
args.emplace_back("HMSET");
args.push_back("hash:" + this->type + ":" + Anope::ToString(obj->id));
args.push_back("hash:" + this->type + ":" + Anope::ToString(obj->object_id));
for (const auto &[key, value] : data.data)
{
@@ -447,7 +447,7 @@ void Updater::OnResult(const Reply &r)
args2.emplace_back("SADD");
args2.push_back("value:" + this->type + ":" + key + ":" + value->str());
args2.push_back(Anope::ToString(obj->id));
args2.push_back(Anope::ToString(obj->object_id));
/* Add to value -> object id set */
me->redis->SendCommand(NULL, args2);
@@ -551,7 +551,7 @@ void SubscriptionListener::OnResult(const Reply &r)
std::vector<Anope::string> args;
args.emplace_back("SREM");
args.push_back("ids:" + type);
args.push_back(Anope::ToString(s->id));
args.push_back(Anope::ToString(s->object_id));
/* Delete object from id set */
me->redis->SendCommand(NULL, args);
@@ -610,7 +610,7 @@ void ModifiedObject::OnResult(const Reply &r)
obj = st->Unserialize(obj, data);
if (obj)
{
obj->id = this->id;
obj->object_id = this->id;
obj->UpdateCache(data);
/* Insert new object values */
@@ -619,7 +619,7 @@ void ModifiedObject::OnResult(const Reply &r)
std::vector<Anope::string> args;
args.emplace_back("SADD");
args.push_back("value:" + st->GetName() + ":" + key + ":" + value->str());
args.push_back(Anope::ToString(obj->id));
args.push_back(Anope::ToString(obj->object_id));
/* Add to value -> object id set */
me->redis->SendCommand(NULL, args);
@@ -628,7 +628,7 @@ void ModifiedObject::OnResult(const Reply &r)
std::vector<Anope::string> args;
args.emplace_back("SADD");
args.push_back("ids:" + st->GetName());
args.push_back(Anope::ToString(obj->id));
args.push_back(Anope::ToString(obj->object_id));
/* Add to type -> id set */
me->redis->SendCommand(NULL, args);
+7 -7
View File
@@ -49,7 +49,7 @@ public:
{
SQLSQLInterface::OnResult(r);
if (r.GetID() > 0 && this->obj)
this->obj->id = r.GetID();
this->obj->object_id = r.GetID();
delete this;
}
@@ -136,7 +136,7 @@ public:
continue;
auto create = this->sql->CreateTable(GetTableName(s_type), data);
auto insert = this->sql->BuildInsert(GetTableName(s_type), obj->id, data);
auto insert = this->sql->BuildInsert(GetTableName(s_type), obj->object_id, data);
if (this->imported)
{
@@ -155,7 +155,7 @@ public:
*/
Result r = this->sql->RunQuery(insert);
if (r.GetID() > 0)
obj->id = r.GetID();
obj->object_id = r.GetID();
}
}
}
@@ -226,8 +226,8 @@ public:
if (this->shutting_down)
return;
Serialize::Type *s_type = obj->GetSerializableType();
if (s_type && obj->id > 0)
this->RunBackground("DELETE FROM `" + GetTableName(s_type) + "` WHERE `id` = " + Anope::ToString(obj->id));
if (s_type && obj->object_id > 0)
this->RunBackground("DELETE FROM `" + GetTableName(s_type) + "` WHERE `id` = " + Anope::ToString(obj->object_id));
this->updated_items.erase(obj);
}
@@ -235,7 +235,7 @@ public:
{
if (this->shutting_down || obj->IsTSCached())
return;
if (obj->id == 0)
if (obj->object_id == 0)
return; /* object is pending creation */
obj->UpdateTS();
this->updated_items.insert(obj);
@@ -262,7 +262,7 @@ public:
{
auto oid = Anope::TryConvert<Serializable::Id>(res.Get(j, "id"));
if (oid.has_value())
obj->id = oid.value();
obj->object_id = oid.value();
else
Log(this) << "Unable to convert id for object #" << j << " of type " << sb->GetName();
+9 -9
View File
@@ -118,12 +118,12 @@ public:
for (const auto &query : create)
this->RunQuery(query);
auto res = this->RunQuery(this->SQL->BuildInsert(GetTableName(s_type), obj->id, data));
if (res.GetID() && obj->id != res.GetID())
auto res = this->RunQuery(this->SQL->BuildInsert(GetTableName(s_type), obj->object_id, data));
if (res.GetID() && obj->object_id != res.GetID())
{
/* In this case obj is new, so place it into the object map */
obj->id = res.GetID();
s_type->objects[obj->id] = obj;
obj->object_id = res.GetID();
s_type->objects[obj->object_id] = obj;
}
}
}
@@ -168,9 +168,9 @@ public:
Serialize::Type *s_type = obj->GetSerializableType();
if (s_type)
{
if (obj->id > 0)
this->RunQuery("DELETE FROM `" + GetTableName(s_type) + "` WHERE `id` = " + Anope::ToString(obj->id));
s_type->objects.erase(obj->id);
if (obj->object_id > 0)
this->RunQuery("DELETE FROM `" + GetTableName(s_type) + "` WHERE `id` = " + Anope::ToString(obj->object_id));
s_type->objects.erase(obj->object_id);
}
this->updated_items.erase(obj);
}
@@ -227,10 +227,10 @@ public:
Serializable *new_s = obj->Unserialize(s, data);
if (new_s)
{
// If s == new_s then s->id == new_s->id
// If s == new_s then s->object_id == new_s->object_id
if (s != new_s)
{
new_s->id = id;
new_s->object_id = id;
obj->objects[id] = new_s;
/* The Unserialize operation is destructive so rebuild the data for UpdateCache.
+2 -2
View File
@@ -159,7 +159,7 @@ public:
std::vector<Query> CreateTable(const Anope::string &table, const Data &data) override;
Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) override;
Query BuildInsert(const Anope::string &table, Serializable::Id id, Data &data) override;
Query GetTables(const Anope::string &prefix) override;
@@ -568,7 +568,7 @@ std::vector<Query> MySQLService::CreateTable(const Anope::string &table, const D
return queries;
}
Query MySQLService::BuildInsert(const Anope::string &table, unsigned int id, Data &data)
Query MySQLService::BuildInsert(const Anope::string &table, Serializable::Id id, Data &data)
{
/* Empty columns not present in the data set */
for (const auto &known_col : this->active_schema[table])
+2 -2
View File
@@ -69,7 +69,7 @@ public:
std::vector<Query> CreateTable(const Anope::string &table, const Data &data) override;
Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) override;
Query BuildInsert(const Anope::string &table, Serializable::Id id, Data &data) override;
Query GetTables(const Anope::string &prefix) override;
@@ -305,7 +305,7 @@ std::vector<Query> SQLiteService::CreateTable(const Anope::string &table, const
return queries;
}
Query SQLiteService::BuildInsert(const Anope::string &table, unsigned int id, Data &data)
Query SQLiteService::BuildInsert(const Anope::string &table, Serializable::Id id, Data &data)
{
/* Empty columns not present in the data set */
for (const auto &known_col : this->active_schema[table])