Bug 22084: Plugin upgrade method and database plugin version storage will never be...
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 8 Jan 2019 18:10:53 +0000 (13:10 -0500)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 27 Feb 2019 14:14:21 +0000 (09:14 -0500)
commit8c2e03020dc02519dec70b9697794a3624c73937
treecc710ec3b4c7bc21bd64fd5f7a1726c3a4b56525
parent57f4c01b9a09d1c2e0fc8a3449ba86574775b840
Bug 22084: Plugin upgrade method and database plugin version storage will never be triggered for existing installs

If an existing plugin begins using the upgrade() method, it will never actually get triggered because the installation has already occurred and no database plugin version was stored at the time. Without that database version, the upgrade method will never be triggered.

In addition, if the plugin has no upgrade method, the installed version is never updated in the database!

Lastly, when an upgrade succeeds it prints a warning that the upgrade failed.

Test Plan:
1) Install an older version of the Kitchen sink plugin:
   * https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.0/koha-plugin-kitchen-sink-v2.1.0.kpz
2) Delete the "__INSTALLED_VERSION__" key, and the "last_upgraded" key from plugin_data for this plugin, to simulate having installed from an earlier version of Koha
3) Upgrade to the latest version of the Kitchen sink plugin:
   * https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.22/koha-plugin-kitchen-sink-v2.1.22.kpz
4) Note "__INSTALLED_VERSION__" still doesn't exist for the plugin, in the plugin_data table
5) Apply this patch
6) Restart all the things
7) Browse to the Kitchen sink configuration page, this should trigger the upgrade method
8) Note the "__INSTALLED_VERSION__" and "last_upgraded" keys exist in plugin_data for the Kitchen Sink plugin

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/Plugins/Base.pm