fix:Fix static property data bleed in RulesValidation #90
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.
Resolve issue where static properties in RulesValidation Trait are shared across multiple classes, causing data bleeding. Added reset method for static properties.
When using the
RulesValidation
Trait, static properties such as*ValidationRules
and*ValidationMessages
are shared across multiple classes. This can lead to data bleeding, especially when a Model inherits from another Model that uses theLift
Trait and multiple database save operations are triggered in the same request.Solution
To resolve this issue, the
resetValidations
method has been added to theRulesValidation
Trait. This method resets the static properties to their initial state before each operation, preventing data bleeding between different Model instances.Changes
resetValidations
method to theRulesValidation
Trait.resetValidations
where necessary to ensure data integrity.This pull request includes changes to improve the consistency and maintainability of the codebase by replacing
self
withstatic
in various methods and adding a new method to reset validation messages.Improvements to method calls:
src/Lift.php
: Replaced all instances ofself
withstatic
in thebootLift
,syncOriginal
,ignoredProperties
, andfillProperties
methods to ensure proper method resolution in subclasses. [1] [2] [3] [4] [5] [6]New functionality:
src/Concerns/RulesValidation.php
: Added a new methodresetValidations
to reset validation messages and rules.This refactoring enhances the flexibility and reusability of the code by allowing subclasses to override static methods more effectively.