Repository navigation
Fixed : Index audits, skip empty translation audits, and fix history preview - #508
Merged
navneetkumar-pim-webkul merged 2 commits intoJun 19, 2026
Conversation
…nd fix attribute history preview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Creating an attribute returns a 504 on installs with a large
auditstable,and viewing an attribute's History failed / showed noise.
Root cause
AttributeTranslationand other translatable models useHistoryTrait, socreating one attribute writes one audit row per active locale. The
audit_before_inserttrigger runs two queries per insert filtering by(tags, history_id), which was never indexed — every insert is a full tablescan, so creation times out as
auditsgrows.created version because the old value is an empty array, and it listed
empty/default fields (
validation,regex_pattern,ai_translate).Changes
audits(tags, history_id)(prefix-aware, idempotent,MySQL + PostgreSQL). The trigger's two lookups become index lookups
(
EXPLAIN:type=ALL→type=ref,rows=1).readyForAuditing()inHistoryTraitto skip auditing atranslatable model when all of its
historyTranslatableFieldsare empty.Non-translatable models (Attribute, Product, Category, …) are unaffected.
AttributeHistoryPresenter::formatValue()against array (empty old)values so the created-version history no longer 500s.
meaningful changes.
preview across every attribute type.
Measured on ~2.1M audit rows: one attribute create dropped from ~138s to ~1.9s;
audit inserts per create dropped from 51 to 2.
How To Test This?
vendor/bin/pest packages/Webkul/Admin/tests/Feature/Catalog/AttributeAuditTest.phpvendor/bin/pest packages/Webkul/Admin/tests/Feature/Catalog/AttributeHistoryViewTest.phpSaves quickly even on a large audits table; open the History tab → view a
version: it renders without error and omits empty fields.
SHOW INDEX FROM audits;showsaudits_tags_history_id_index (tags, history_id).Checklist
vendor/bin/pestpasses locally (new tests — 33 passed)vendor/bin/pint --testreports no style issuesTarget branch is
master