Bug 22084

Summary: Plugin upgrade method and database plugin version storage will never be triggered for existing installs
Product: Koha Reporter: Kyle M Hall <kyle>
Component: Architecture, internals, and plumbingAssignee: Kyle M Hall <kyle>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: normal    
Priority: P5 - low CC: dcook, fridolin.somers, jesse, josef.moravec, martin.renvoize, nick, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 20669    
Bug Blocks:    
Attachments: Bug 22084: Plugin upgrade method and database plugin version storage will never be triggered for existing installs
Bug 22084: Regression tests
Bug 22084: Plugin upgrade method and database plugin version storage will never be triggered for existing installs
Bug 22084: Regression tests
Bug 22084: Plugin upgrade method and database plugin version storage will never be triggered for existing installs
Bug 22084: Regression tests
Bug 22084: Plugin upgrade method and database plugin version storage will never be triggered for existing installs

Description Kyle M Hall 2019-01-08 18:10:38 UTC
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.
Comment 1 Kyle M Hall 2019-01-08 18:32:37 UTC
Created attachment 83726 [details] [review]
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
Comment 2 Tomás Cohen Arazi 2019-01-09 10:34:55 UTC
Created attachment 83734 [details] [review]
Bug 22084: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 3 Tomás Cohen Arazi 2019-01-09 10:35:01 UTC
Created attachment 83735 [details] [review]
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>
Comment 4 Kyle M Hall 2019-01-09 12:48:05 UTC
Created attachment 83740 [details] [review]
Bug 22084: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 5 Kyle M Hall 2019-01-09 12:48:35 UTC
Created attachment 83741 [details] [review]
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>
Comment 6 Josef Moravec 2019-02-20 16:27:37 UTC
Created attachment 85384 [details] [review]
Bug 22084: Regression tests

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>
Comment 7 Josef Moravec 2019-02-20 16:27:42 UTC
Created attachment 85385 [details] [review]
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>
Comment 8 Nick Clemens (kidclamp) 2019-02-27 14:18:18 UTC
Awesome work all!

Pushed to master for 19.05
Comment 9 Martin Renvoize 2019-03-01 11:41:39 UTC
Pushed to 18.11.x for 18.11.04

rmaint note: the parent bug for this was backported all the way to 17.11.x series so we need it all the way down.
Comment 10 Jesse Maseto 2019-03-08 19:36:14 UTC
Pushed to 18.05.x for 18.05.11