🐛 Only offer states from classes with a lifecycle in AttributeClassState#893
Open
larhip wants to merge 1 commit intoCombodo:developfrom
Open
🐛 Only offer states from classes with a lifecycle in AttributeClassState#893larhip wants to merge 1 commit intoCombodo:developfrom
larhip wants to merge 1 commit intoCombodo:developfrom
Conversation
When enumerating allowed states in AttributeClassState::GetAllowedValues(), child classes that have a state attribute but no lifecycle transitions (stimuli) were included. TriggerOnStateChange only fires on actual lifecycle state changes, so states from classes without a lifecycle would never trigger — but were still offered in the UI. Fix: skip child classes where MetaModel::HasLifecycle() returns false.
Contributor
|
There is an existing bug: N°6464 - Make TriggerOnStateChange working when the state attribute is not in a lifecycle |
Hipska
approved these changes
Apr 24, 2026
Hipska
approved these changes
Apr 24, 2026
Contributor
Author
Wasn't aware of that bug, since I am not able to see this one 😅 |
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.
Base information
Symptom
When configuring a
TriggerOnStateChange(or its subclassesTriggerOnStateEnter/TriggerOnStateLeave), the State dropdown offers states from classes that have a state attribute but no lifecycle transitions. Selecting such a state results in a trigger that will never fire, sinceTriggerOnStateChangeonly activates on actual lifecycle state changes (i.e. when a stimulus is applied).Example: A class like
Personmay have anstatusattribute with valuesactive/inactive, but no stimuli/transitions defined. Its states appeared in the dropdown even though no lifecycle change can ever occur on it.Reproduction procedure
TriggerOnStateChangeTriggerOnStateEnterorTriggerOnStateLeaveTarget classto a class that has a state attribute but no lifecycle (e.g.Person—active/inactivestates, no transitions)Statedropdownactive,inactiveforPerson)Cause
AttributeClassState::GetAllowedValues()iterates over all child classes of the selected target class and collects their states viaMetaModel::EnumStates(). This method returns states for any class with a state attribute, regardless of whether that class has lifecycle transitions (stimuli).TriggerOnStateChange(and its concrete subclasses) only fires when a state change is triggered by a stimulus — i.e. only for classes with a full lifecycle. The distinction already exists in the codebase:MetaModel::HasStateAttributeCode()— class has a state attributeMetaModel::HasLifecycle()— class has a state attribute and at least one stimulusGetAllowedValues()was using the weaker check (implicitly viaEnumStates()), but should use the stricterHasLifecycle().Proposed solution
In
AttributeClassState::GetAllowedValues(), skip child classes for whichMetaModel::HasLifecycle()returnsfalsebefore collecting their states:MetaModel::HasLifecycle()already encapsulates exactly the right condition:The change is 3 lines, confined to
sources/Core/AttributeDefinition/AttributeClassState.php, and has no impact on classes that do have a lifecycle.Checklist before requesting a review