From f8a8dd2c2931acccccea077fae549273c119de46 Mon Sep 17 00:00:00 2001 From: Nils Goroll Date: Tue, 17 Feb 2026 00:52:56 +0100 Subject: [PATCH] chore: remove `_old_uid` hack (#11277) The virtual session code creates an in-memory session, and only upon release does it copy it to the actual session store. This makes a lot of sense to avoid operations on session stores with potentially high cost for I/O. This commit removes a weird hack used in this code: virtual sessions were always created with an _old_uid=0 key/value pair, which was taken into account when checking if the session needed to be persisted. As I could not find _any_ use of _old_uid in the code base, this looks like something worth removing. The first ever mention of _old_uid is b33f7f792bf3a1a1e54639db94cc80b84f68ebfd and even there it is part of a newly added file with no additional information. So likely code copied over from another project? - no tests to add, remove or change - not relevant for documentation - not relevant for release notes Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11277 Reviewed-by: Gusted Co-authored-by: Nils Goroll Co-committed-by: Nils Goroll --- modules/session/virtual.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/session/virtual.go b/modules/session/virtual.go index 1c3e1c778b..1986ba64ad 100644 --- a/modules/session/virtual.go +++ b/modules/session/virtual.go @@ -64,7 +64,6 @@ func (o *VirtualSessionProvider) Read(sid string) (session.RawStore, error) { return o.provider.Read(sid) } kv := make(map[any]any) - kv["_old_uid"] = "0" return NewVirtualStore(o, sid, kv), nil } @@ -159,7 +158,7 @@ func (s *VirtualStore) Release() error { // Now need to lock the provider s.p.lock.Lock() defer s.p.lock.Unlock() - if oldUID, ok := s.data["_old_uid"]; (ok && (oldUID != "0" || len(s.data) > 1)) || (!ok && len(s.data) > 0) { + if len(s.data) > 0 { // Now ensure that we don't exist! realProvider := s.p.provider