-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command to fix incorrectly deleted fields from containers tables #525
Add command to fix incorrectly deleted fields from containers tables #525
Conversation
Even if such a solution would work, I think it would be better to delete data from DB when field/dropdown is deleted, for instance in |
Looking at |
It seems it was only done to improve performances (see 5d087e1). IMHO, not deleting data from DB when deleting a field is a problem and should be fixed. |
Values were cleaned in old plugin db schema, and this clean has not been adapted to new schema, see 455c2c2. |
Maybe the deletion chain should be reviewed.
|
Actually, after re-reading the code I've found that deletion was just broken since 1.15.0.
|
I'm not sure about a migration to remove the missing fields... any mistake which would delete legitimate fields would have a huge impact. |
7f6d9e9
to
dd4eff6
Compare
// header type is for read-only display purpose only and has no SQL field | ||
break; | ||
case $field_type === 'dropdown': | ||
case preg_match('/^dropdown-.+/i', $field_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case preg_match('/^dropdown-.+/i', $field_type):
was a legitimate case and should be preserved.
Diff is huge here, and it is hard to validate the code. Unless I am wrong, if #528 is merged, only the new command and corresponding PluginFieldsMigration
methods are required.
I would prefer serarate PR for PSR-12 migration and for migration of PHP template files to abstract classes (should be done globally). We could work on these later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's merge #528 and then I'll open separate PR for each topics.
PS: for the huge diff, it's mostly whitespaces and you can ignore them:
Replaced by #532. |
Internal ref: !24075.
EDITED after #526 (see comments)
An issue affected field removal in 1.15.0, 1.15.1 and 1.15.2.
Using these versions, removing a field from a container would drop the field from glpi_plugin_fields_fields but not from the custom container table.
This command remove these incorrectly deleted fields.
Command examples:

Unrelated changes kept from the previous iteration:
PluginFieldsContainerTemplate
base class for custom containers classes in order to reduce the generated php classes for each containers.The main advantage is that you can edit the generic code directly from
PluginFieldsContainerTemplate
and it will impact all custom container classes without having to "regenerate" the PHP files of these custom classes.