fix: always defer access log insertion (#32976)

This commit is contained in:
Sagar Vora 2025-06-18 01:33:11 +00:00 committed by GitHub
parent 514a9a6e59
commit e355a175d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,13 +54,10 @@ def make_access_log(
page=None,
columns=None,
):
user = frappe.session.user
in_request = frappe.request and frappe.request.method == "GET"
access_log = frappe.get_doc(
{
"doctype": "Access Log",
"user": user,
"user": frappe.session.user,
"export_from": doctype,
"reference_document": document,
"file_type": file_type,
@ -72,18 +69,11 @@ def make_access_log(
}
)
if frappe.flags.read_only:
if not frappe.in_test:
access_log.deferred_insert()
return
else:
access_log.db_insert()
# `frappe.db.commit` added because insert doesnt `commit` when called in GET requests like `printview`
# dont commit in test mode. It must be tempting to put this block along with the in_request in the
# whitelisted method...yeah, don't do it. That part would be executed possibly on a read only DB conn
if not frappe.in_test or in_request:
frappe.db.commit()
# only for backward compatibility
_make_access_log = make_access_log