mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
SugarBean->cleanBean performance issue #4181
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#4181
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @PedroErnst on GitHub (Dec 31, 2019).
The
cleanBeanfunction has a negative impact on performance.Issue
Inside the bean save function
cleanBean()is called to remove potentially malicious code. This function will callSugarCleaner::cleanHtml()on every text, html or varchar field on the bean.The problem lies in that this function creates a new
HtmlSanitizerobject each time, and the constructor ofHtmlSanitizeris badly bloated, executing a lot of things which would probably only need to run once per page load, not dozens of times per save operation.On some test on my local
cleanBean()was taking as much as 80% of the total time spent in thesave()function.Now this would hardly be noticeable in many of the regular CRM interactions, loading a page, a listview, detailview, saving a single record... etc, but there's a few functionalities where it really tanks performance: Importer and Mass Update.
The
HtmlSanitizerconstructor can probably be refactored to do less things, or converted into a singleton class to avoid being instantiated every time.Expected Behavior
cleanBean()should be fast, it's essentially string processing.Actual Behavior
cleanBean()takes an unreasonable amount of time to run.Possible Fix
Refactor
HtmlSanitizerto be singleton class, or make the constructor leaner.Steps to Reproduce
SugarBean->save()Your Environment
@Jason-Dang commented on GitHub (Dec 31, 2019):
This should probably be higher priority as performance should be critical IMO.
@Dillon-Brown commented on GitHub (Dec 31, 2019):
@Jason-Dang I'm thinking we probably need a label specifically for performance, I also didn't like giving this one just "Clean-Up" and "Low Priority".
In terms of the priority labels though, the performance would need to be bad enough that it's timing out / unusable to be worth marking higher. At the moment we have roughly 15 high priority blockers with limited or no-workaround that need to be tackled first before we can even start thinking about performance bugs imo.