perf: use lazy doc for permission checks 🚀
Co-Authored-By: Sagar Vora <sagar@resilient.tech>
This commit is contained in:
parent
4d7348d3c0
commit
beefdb9a1f
2 changed files with 5 additions and 2 deletions
|
|
@ -847,7 +847,7 @@ def has_website_permission(doc=None, ptype="read", user=None, verbose=False, doc
|
|||
|
||||
if doc:
|
||||
if isinstance(doc, str):
|
||||
doc = get_doc(doctype, doc)
|
||||
doc = get_lazy_doc(doctype, doc)
|
||||
|
||||
doctype = doc.doctype
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,10 @@ def has_permission(
|
|||
|
||||
if doc:
|
||||
if isinstance(doc, str | int):
|
||||
doc = frappe.get_doc(meta.name, doc)
|
||||
if meta.is_virtual or doctype == "DocType":
|
||||
doc = frappe.get_doc(meta.name, doc)
|
||||
else: # perf: Avoid loading child tables for perm checks
|
||||
doc = frappe.get_lazy_doc(meta.name, doc)
|
||||
perm = get_doc_permissions(doc, user=user, ptype=ptype, debug=debug).get(ptype)
|
||||
if not perm:
|
||||
debug and _debug_log(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue