Action class variables should not be accessed directly. Functions should be use to access the variable. For instance use getDescription() and setDescription($description) for the protected class variable description. For a boolean variable the getter function becomes isVariableName(). In object-oriented programming this is called encapsulation.
Remaining tasks
- Update the class variables and make them protected.
- Create getters and setters for frequently used get and set functionality.
- Update drupal to use the getters and setters instead of accessing variables directly.
- There are no tests required because the added functions are only getters and setters.
For more info over what should be done see the issue summary of #2016679: Expand Entity Type interfaces to provide methods, protect the properties.
Beta phase evaluation
Issue category | Bug because properties should not be public, API methods should not be allowed to be sidestepped. |
---|---|
Issue priority | Major because this meta goes across the entire system. But each child will be a normal bug. |
Prioritized changes | Prioritized since it is a bug and it reduces fragility. |
Disruption | Somewhat disruptive for core as well as contributed and custom modules:
|
But impact will be greater than the disruption, so it is allowed in the beta.
Comment | File | Size | Author |
---|---|---|---|
#11 | 9394699-11.patch | 532 bytes | areke |
Comments
Comment #1
daffie CreditAttribution: daffie commentedI would like to get this fixed. So I will do a good review for posted patches.
Comment #2
daffie CreditAttribution: daffie commentedThe class variables $id and $label need to become protected.
You can use the functions id() as a getter function for the $id variable and label() as a getter function for the variable $label.
Comment #3
daffie CreditAttribution: daffie commentedThe action entity is defined in the system module.
Comment #4
areke CreditAttribution: areke commentedComment #5
areke CreditAttribution: areke commentedLet's try this.
Comment #6
daffie CreditAttribution: daffie commentedThese functions are inherited from the Entity class. So they can be removed.
These functions are not used. You can remove them and use set('id', $value) and set('label', $value).
Comment #7
daffie CreditAttribution: daffie commentedComment #8
areke CreditAttribution: areke commentedComment #9
areke CreditAttribution: areke commentedComment #10
daffie CreditAttribution: daffie commented@areke: Something went wrong with creating your last patch. :(
Comment #11
areke CreditAttribution: areke commentedComment #13
daffie CreditAttribution: daffie commentedAll the class variables are protected.
There are already getter functions available, so no need for new ones.
The test-server give it green.
It all looks good to me, so for me it is RTBC.
Comment #14
craigsilk CreditAttribution: craigsilk commentedOut of curiosity, was / is there any code that sets these variables directly rather than through the inherited get() and set() methods?
Comment #15
daffie CreditAttribution: daffie commented@craigsilk: The getter function for the variable $id is id() and the getter for the variable $label is label(). If you want to set the variable $id or $label you must use the set() function.
Comment #16
alexpottCommitted 7ee91de and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation for to the issue summary.