Not planned More validations when administrator removes an addons

Kruzya

Well-known member
I'm think this is a partially bug.
Let's go simulate a simple situation:
  1. Administrator tries install addon B and got an error about non-installed addon A.
  2. Administrator installs addon A. Addon A creates in database table xf_a_provider.
  3. Administrator installs addon B. Addon B is depends on addon A, and inserts in table xf_a_provider something entry.
  4. Administrator removes addon A. Addon removes all data (with table in database) correctly.
  5. Administrator tries remove addon B and got an error about non-existent table xf_a_provider and "dead" addon.
On fourth step, administrator should receive a error in style like "You have addons where this addon is required for work" and get a list where addon A is marked as "required for work".
 
Upvote 1
This suggestion has been closed. Votes are no longer accepted.
The onus for this is really on the add-on developer(s) who are dealing with a table that both add-ons expect to exist.

You can either catch the exception or check if the table exists before attempting to drop it.
 
It seems like you have been inattentively reading the simulated situation.
Addon B doesn't creates any tables and don't performs drop operations in Setup, it just writes/removes one entry in table from addon A.
For what purposes we should in uninstall code in addon B verify table existing, if we're already declared requirement addon A in addon.json?
 
It would be checking if the table exists, and if not then it obviously can not drop the column it needs to (because the column is gone with the table), so in that case it should error out silently and carry on with uninstall process.
 
@ozzy47, i did not say a word about the table columns. I talk about entries (rows) in table.
And in this case i can't understand, for what reasons we fill require object in addon.json if XF can allow delete addon on which depends another addons without any error/warning.
 
Same scenario, column, entry. Addon B should check if table exists while uninstalling and if it don't error out silently and very on with the process.
 
Try delete any standard library with package manager in Linux. It will also remove all related software.
for what reasons we fill require object in addon.json if XF can allow delete addon on which depends another addons without any error/warning
XF should have similar behavior (remove all addons where addon A is marked as "required") or throw an error with add-on list. This is my vision in this situation, of course.
 
It would honestly be really nice to have more validation on this. A simple "uninstalling this add-on will also uninstall/deactivate this add-on that has it as dependency" would be a very solid feature. Yes, the uninstaller should still consider that the add-on that is being relied on may not be present, but there's a lot more to consider here:
If I build on an add-on that offers certain functionality, aka. an extension for it, then I'll have to build in checks all nose long to avoid having a flood of errors everwhere. Doing a template mod that relies on functions offered by the required add-on? Need to wrap them all in is_addon_active(). Extending any piece of code and need a function of said add-on? Have to check the add-on cache om whether it's active/installed. It just sums up, and it could easily be avoided by disabling the add-on along with its requirement.
 
Back
Top Bottom