[CWB] Delete corpus with plugin enabled
Uhrig, Peter
peter.uhrig at fau.de
Thu Apr 15 14:53:38 CEST 2021
Thanks a lot!
BTW: Does Sourceforge allow for something like pull requests?
Best wishes,
Peter
Von: cwb-bounces at sslmit.unibo.it <cwb-bounces at sslmit.unibo.it> Im Auftrag von Hardie, Andrew
Gesendet: Donnerstag, 15. April 2021 14:20
An: Open source development of the Corpus WorkBench <cwb at sslmit.unibo.it>
Betreff: Re: [CWB] Delete corpus with plugin enabled
Here's the patch you need. It'll be in my next commit to cqpweb as well (I can't commit right now due to tricky mix of patches on my own box)
Andrew.
==========================================================
Index: corpus-lib.php
===================================================================
--- corpus-lib.php (revision 1584)
+++ corpus-lib.php (working copy)
@@ -1256,6 +1256,10 @@
/* CWB data now clean: on to the MySQL database. All these queries are "safe":
* they will run OK even if some of the expected data has already been deleted. */
+ /* unassociate plugins, etc. */
+
+ deactivate_all_plugins_for_corpus($info->id);
+
/* delete all saved restrictions, saved queries, saved frequency tables, and saved dbs associated with this corpus */
uncache_restrictions_by_corpus($info->id);
Index: plugin-lib.php
===================================================================
--- plugin-lib.php (revision 1584)
+++ plugin-lib.php (working copy)
@@ -1988,6 +1988,12 @@
activate_plugin_for_corpus($plugin_id, $cid, PRIVILEGE_TYPE_CORPUS_RESTRICTED);
}
+
+function deactivate_all_plugins_for_corpus(int $corpus_id) : void
+{
+ do_sql_query("delete from plugin_activations where corpus_id = $corpus_id");
+}
+
/**
* Get the string that names an interface from a plugin type constant.
* Returns null if the argument is invalid.
From: cwb-bounces at sslmit.unibo.it<mailto:cwb-bounces at sslmit.unibo.it> <cwb-bounces at sslmit.unibo.it<mailto:cwb-bounces at sslmit.unibo.it>> On Behalf Of Uhrig, Peter
Sent: 15 April 2021 12:35
To: Open source development of the Corpus WorkBench <cwb at sslmit.unibo.it<mailto:cwb at sslmit.unibo.it>>
Subject: [CWB] Delete corpus with plugin enabled
Dear all,
when we delete a corpus from a CQPweb instance with an activated plugin, the plugin activation is not automatically deleted from the plugin_activations table. This causes a "invalid corpus id" error on the plugin activation page. We had to manually remove the old activation from the table in MySQL.
Best wishes,
Scott & Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://liste.sslmit.unibo.it/pipermail/cwb/attachments/20210415/3294d052/attachment-0001.html>
More information about the CWB
mailing list