← Back to team overview

mahara-contributors team mailing list archive

[Bug 1471227] Re: Unable to delete an institution

 

Investigated a bit further... it's simple really.

The routine that deletes the authentication instances for an Institution
is incomplete. It fails to delete the entries from auth_instance_config
before trying to delete the instance from auth_instance.

Proof....

Here is the original error (on my site)...

ariaDB [mahara15]> DELETE FROM auth_instance  WHERE institution = 'arts';
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`mahara15`.`auth_instance_config`, CONSTRAINT `authinstconf_ins_fk` FOREIGN KEY (`instance`) REFERENCES `auth_instance` (`id`))

SO...

MariaDB [mahara15]> select * from auth_instance where institution='arts';
+----+--------------+----------+-------------+----------+
| id | instancename | priority | institution | authname |
+----+--------------+----------+-------------+----------+
| 14 | artsLdap     |        0 | arts        | ldap     |
| 15 | artsXmlrpc   |        1 | arts        | xmlrpc   |
+----+--------------+----------+-------------+----------+

This Institution has two auth instances... so...

MariaDB [mahara15]> select * from auth_instance_config where instance in (14,15);
+----------+-------------------+-----------------------------------------------------+
| instance | field             | value                                               |
+----------+-------------------+-----------------------------------------------------+
|       14 | bind_dn           |                                                     |
|       14 | bind_pw           |                                                     |
|       14 | contexts          | ou=student,o=gla;o=gla                              |
|       14 | emailfield        |                                                     |
|       14 | firstnamefield    |                                                     |
|       14 | host_url          | ldap:..... |
|       14 | search_sub        | yes                                                 |
|       14 | surnamefield      |                                                     |
|       14 | user_attribute    | uid                                                 |
|       14 | user_type         | edir                                                |
|       14 | version           | 2                                                   |
|       14 | weautocreateusers | 0                                                   |
|       15 | parent            | 14                                                  |
|       15 | theyssoin         | 1                                                   |
|       15 | weautocreateusers | 1                                                   |
|       15 | wwwroot           | http://.....                        |
+----------+-------------------+-----------------------------------------------------+

One would assume it should have deleted that first. The only method that
allows an Institution to be deleted is internal authentication as that
has no parameters.

Oddly, deleting the instances from within the Institution one at a time
(and adding an Internal one) works fine - so the code must be different
(I haven't looked)

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1471227

Title:
  Unable to delete an institution

Status in Mahara ePortfolio:
  Incomplete

Bug description:
  Mahara 15.04. MySQL database

  Removed all users from an Institution and attempted to delete it. On
  confirmation am SQL error was generated:

  [WAR] f4 (lib/errors.php:747) Failed to get a recordset: mysqli error: [1451: Cannot delete or update a parent row: a foreign key constraint fails 
  ("mahara15"."auth_remote_user", CONSTRAINT "authremouser_aut_fk" FOREIGN KEY ("authinstance") REFERENCES "auth_instance" ("id"))] in adodb_throw(DELETE FROM "auth_instance"  WHERE "institution" = 'education' , )
  Command was: DELETE FROM "auth_instance"  WHERE "institution" = ?  and values was (education)

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1471227/+subscriptions


References