paulgibbs / achievements

Achievements gamifies your WordPress site with challenges, badges, and points.
http://achievementsapp.com
63 stars 9 forks source link

Bumping the version number doesn't cause actions to update #105

Closed rmccue closed 11 years ago

rmccue commented 11 years ago

In dpa_maybe_update_extensions(), actions are added as terms to the database if the extension hasn't been seen before. The documentation for DPA_Extension::$version indicates that bumping the version number will cause this to be updated, however this is not the case.

The only way to cause actions to be added is to change the extension's ID.

(In addition, there's no way to remove an action from the terms, which can cause the database to be bloated, and additional hooks to be run unnecessarily when removing actions.)

The recommended quick fix for this is to also insert the missing terms if an update is required (which is the next if statement).

A better fix would be to get the registered terms locally and array_diff them with the terms in the database in the $orig_versions != $versions block. This allows adding new terms, updating descriptions and removing unneeded actions.

paulgibbs commented 11 years ago

You are correct that the check isn't looking at the version, but the ID. Not intentional.

The idea is that the first time an extension is seen, it will be "installed" (added to the taxonomy) automatically. For handling any "upgrade" for a newer version of the same extension, it is intended to be up to the extension to implement that logic in the do_update method.

paulgibbs commented 11 years ago

I misread in my earlier update. Everything is working as expected. Any upgrade steps are expected to be manually dealt with by the extension.

Closing this because upon testing (with this example change https://gist.github.com/paulgibbs/bc4122e84467ba980dcf), it is working as expected.