Problem/Motivation
This module's initial code was not structured perfectly and is starting to smell.
We now have key properties defined in several places, which is confusing and will lead to stale code:
- In the config schema (which was added later)
- In $property_info in the key types
- In the code of KeyPair::getKeyProperties() (which just sets properties without thinking about the schema)
$property_info determines which properties are displayed when the "Info" button is pressed, without looking at the schema. This is unnecessary / leads to smelly code.
getKeyProperties() just sets whatever properties it wants, without looking at the schema. Thats's fine IMHO, because
- these properties are not required values
- If a property is set without being defined at the same time, the "Add key" screen (Drupal Core) emits a warning** about the missing schema, when saving. So we'll see and fix it.
** Or, depending on settings, a fatal error? Functional tests fail when saving a key, whereas a 'simple' manual test only shows a warning message.
2)
Some properties are not defined in the schema, and are not meant to be saved - only meant to display though the "Info" button. (Specifically: 'comment'.) At the moment, these are saved to the config object with a warning.
Proposed resolution
Remove the definitions for $property_info and use the config schema instead, for validation before saving.
To define / support the 'info only' properties, introduce a new constant (in the place of $property_info).
Result: it's clearer where to change what, when properties are added in the future.
No functional changes, besides warnings being gone. Tested manually.
Issue fork key_asymmetric-3573615
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
roderikMerged immediately, because this is mostly my own old code, and so that I can update #3492478: Remove dependency on phpseclib.
Comment #6
roderik