
Originally Posted by
DrByte
Both approaches have merit.
With respect, I believe you have missed my point.

Originally Posted by
DrByte
The one swguy mentioned is most appropriate in the event user-interaction is recommended as a result of the changes
This is where you seem to have missed the point that this exact same user-interaction is also possible with my solution.

Originally Posted by
DrByte
The approach RodG mentioned is ideal if no user interaction is needed.
I *knew* I shouldn't have mentioned the 'icing on the cake', because it has clearly led you into over thinking it.

Originally Posted by
DrByte
If an addon doesn't have internal version number checking anywhere, then a simple check for missing configuration keys or outdated components would be an equally suitable alternative to version checking.
This is the significant point of this discussion as far as I'm concerned. Problems can/will only arise if the database is out of sync with the files, so to avoid any such problems this situation needs to be detected somehow.
What happens if/when a mismatch is found is a different ballgame. Either of the proposed solutions can be made to either produce a "Missing Keys you should reinstall!" alert, or, as in the case of ozpost, simply force the re-install.
It is the method of detecting the database/file mismatch that is of interest here.
The 'gold' solution suggested by swguy, is, as I previously stated/implied is flawed in that it will only detect a problem if configuration keys have been added or removed, thus resulting in a count mismatch. The solution that I've implemented actually uses a little less code and is somewhat more reliable because it can/will generate an alert if the configuration_key counts remain constant such as could occur if an old key is removed and a totally different one is added.
It only takes one line of code like:
Code:
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, c
onfiguration_description, configuration_group_id, sort_order, date_added) values ('DBversion', 'MODULE_SHIPPING_OZPOST_DB
_VERS', '$this->VERSION', 'Internal use only. Used to ensure databases and files remain syncronised', '6', '90', now())")
;
To initialise the database entry (at the same time as the original module install and/or during the remove/reinstall process).
Then in the check() function another line such as
Code:
if (($this->VERSION) && (MODULE_SHIPPING_OZPOST_DB_VERS) && ($this->VERSION != MODULE_SHIPPING_OZPOST_DB_VERS)) {
// generate alert , or do other upgrade stuff //
}
If swguy's solution is 'the gold' standard, then surely this simpler and more robust method should be considered the 'platinum' standard.
I probably wouldn't have mentioned this other than the fact that I did actually use the configuration key count method myself for a while, until it failed for the exact same reason that it will eventually fail for swguy or others that use this method
I mean no disrespect to swguy or the solution proposed. I saw the flaw/shortcoming as a result of 1st hand experience, and it isn't in my nature to watch others fall into the same traps without saying something.
Cheers
Rod
Bookmarks