artefact installed upgrade problem

Bug #1287344 reported by Robert Lyon on 2014-03-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Low
Nigel Cunningham

Bug Description

When there is an artefact plugin missing and one tries to upgrade another artefact plugin there is an error:

[WAR] cb (lib/errors.php:739) Failed to get a recordset: postgres7 error: [-1: ERROR: update or delete on table "artefact_installed_type" violates foreign key constraint "arte_art_fk" on table "artefact", referer: https://mahara-testing/admin/upgrade.php
[Tue Mar 04 08:52:46 2014] [error] [client 127.0.0.1] [WAR] cb (lib/errors.php:739) DETAIL: Key (name)=(socialprofile) is still referenced from table "artefact".] in adodb_throw(DELETE FROM "artefact_installed_type" WHERE (plugin = ? AND name NOT IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)), Array), referer: https://mahara-testing/admin/upgrade.php

This is due to the fact the missing plugin has artefacts in the artefact table.

This line in lib/upgrade.php (approx line 500)

            delete_records_select('artefact_installed_type', $select,
                                  array_merge(array($pluginname),$types));

needs to have some sort of checking if associated items exist for the plugin being removed and remove them first (or have some try { } catch (Exception $e) {} to let the user know that there was an issue with plugin A but still allow plugin B to be upgraded.

Aaron Wells (u-aaronw) wrote :

See also: https://bugs.launchpad.net/mahara/+bug/505732

Deleting plugins is semi-supported in Mahara. We don't provide a way to do it through the UI, but there is one sentence about it in the manual (http://manual.mahara.org/en/1.5/site_admin/extensions.html ): "In order to delete a plugin completely, you must delete the code and all database tables that pertain to the plugin."

It would appear that this advice is incomplete. It's not enough just to delete the plugin's own tables (e.g. "artefact_resume_book"). You also need to delete it from several system tables (e.g. "artefact", "artefact_config", "artefact_cron", etc). Here's an oldish wiki page showing all the many things you have to delete to clear out an artefact plugin: https://wiki.mahara.org/index.php/Plugins/Artefact/My_Learning/Uninstalling

So, the least we could do on this, is update the manual to be a bit more comprehensive.

Updated the manual for 1.7, 1.8 and 1.9

Aaron Wells (u-aaronw) on 2014-04-14
Changed in mahara:
milestone: 1.9.0 → 1.10.0
Changed in mahara:
assignee: nobody → Nigel Cunningham (nigelc-g)
Nigel Cunningham (nigelc-g) wrote :

Tried to reproduce this, without success so far.

I'm happy to implement support for deleting the data of missing plugins if that will help this bug along.

Robert Lyon (robertl-9) wrote :

To test:

Check out an older version of mahara - say 1.8_STABLE and install it.

Then add some dummy data to the database to mimic this process:
- Install thirdparty plugin - use plugin to add an artefact to the artefact table - delete plugin before upgrading.

INSERT INTO artefact_installed_type values ('testing','internal');
INSERT INTO artefact VALUES ((SELECT MAX(id) + 1 FROM artefact), 'testing',0, null, 1, null,null, '2014-08-05 10:11:12', '2014-08-05 10:11:12', '2014-08-05 10:11:12', 0, 'testing', 'this is a test', null, 1, null, 0, 0, null, null, null);

Now checkout latest master and try to upgrade - we get the error.

The question is do we want to scrub the old data? I believe we want to keep it due to this scenario:

- Using plugin fine before upgrade
- Plugin is not compatible with newer version of mahara so user removes it from disk
- Later on an updated version of plugin is available so we install it and expect our old data still to be there.

So we need a way for the system to ignore the deleting of artefact_installed_type if the plugin is missing but still has artefact data we want to keep.

Aaron Wells (u-aaronw) wrote :

Hi Nigel,

If you wanted to implement support for deleting plugins, that'd be great. It's a long-requested feature. I'd start with https://bugs.launchpad.net/mahara/+bug/505732 (support for manually deleting plugins), and from there expand to the ability to clear out the data of "missing" plugins.

Cheers,
Aaron

Changed in mahara:
milestone: 1.10.0 → 1.11.0
importance: High → Low
Aaron Wells (u-aaronw) wrote :

Changing to low priority because Mahara doesn't really support deleting plugins.

Thanks Aaron.

I've been pulled off Mahara for a while to focus on some Moodle dev for
a client, and was going to get stuck into bug fixes and improvements to
the CSV import and export functionality. I'll happily look at this too.
Would you prioritise it higher than the CSV import/export?

Regards,

Nigel

On 12/08/14 08:44, Aaron Wells wrote:
> Hi Nigel,
>
> If you wanted to implement support for deleting plugins, that'd be
> great. It's a long-requested feature. I'd start with
> https://bugs.launchpad.net/mahara/+bug/505732 (support for manually
> deleting plugins), and from there expand to the ability to clear out the
> data of "missing" plugins.
>
> Cheers,
> Aaron
>
> ** Changed in: mahara
> Milestone: 1.10.0 => 1.11.0
>
> ** Changed in: mahara
> Importance: High => Low
>

Changed in mahara:
status: Confirmed → In Progress
Aaron Wells (u-aaronw) on 2015-04-16
Changed in mahara:
milestone: 15.04.0 → 15.10.0
Jinelle Foley-Barnes (jinelleb) wrote :

Hi Rob,

Do you still have the dummy plugin that I can test with?

Thanks,
Jinelle

^ignore comment :)

Aaron Wells (u-aaronw) on 2015-10-23
Changed in mahara:
milestone: 15.10.0 → 16.04.0
Aaron Wells (u-aaronw) on 2016-04-28
Changed in mahara:
milestone: 16.04.0 → 16.10.0
Robert Lyon (robertl-9) on 2016-10-20
Changed in mahara:
milestone: 16.10.0 → 16.10.1
Robert Lyon (robertl-9) on 2016-10-21
Changed in mahara:
milestone: 16.10.1 → 17.04.0
Robert Lyon (robertl-9) on 2017-03-29
Changed in mahara:
milestone: 17.04.0 → 17.10.0
Robert Lyon (robertl-9) on 2017-09-18
Changed in mahara:
milestone: 17.10.0 → 18.04.0

Reviewed: https://reviews.mahara.org/3716
Committed: https://git.mahara.org/mahara/mahara/commit/606eff4ab70c96cd42c624d9eeabc90058e579fb
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 606eff4ab70c96cd42c624d9eeabc90058e579fb
Author: Nigel Cunningham <email address hidden>
Date: Thu Dec 18 16:10:07 2014 +1100

Bug1287344: Don't try to delete missing artefact plugins' data

Don't try to delete the data of missing artefact plugins when
upgrading. The user might want the data but be unable to get
a matching version at the moment.

behatnotneeded: DB upgrading

Change-Id: I52dfec0d97a4bf36a96ca41823c8203f5abb8c73
Signed-off-by: Nigel Cunningham <email address hidden>

Robert Lyon (robertl-9) on 2017-11-21
Changed in mahara:
status: In Progress → Fix Committed
Robert Lyon (robertl-9) on 2018-04-05
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers