** Changed in: mahara/19.04
     Assignee: (unassigned) => Cecilia Vela Gurovic (ceciliavg)

-- 
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/1808935

Title:
  Error Deleting External App - Foreign Key Constraint

Status in Mahara:
  Triaged
Status in Mahara 18.10 series:
  Triaged
Status in Mahara 19.04 series:
  Triaged

Bug description:
  Mahara: 18.10.0
  OS: Linux
  DB: Postgres
  Browser: FF

  I created an LTI integration with a vanilla Moodle 3.5 and set it up
  as an external app.

  I did log in with it from Moodle with an assignment. I think decided
  to delete the app. I get the following error:

  [WAR] ff (lib/errors.php:858) Failed to get a recordset: postgres8 error: 
[-1: ERROR:  update or delete on table "oauth_server_registry" violates foreign 
key constraint "ltiasse_oau_fk" on table "lti_assessment"
  DETAIL:  Key (id)=(1) is still referenced from table "lti_assessment".] in 
EXECUTE("
                      DELETE FROM "oauth_server_registry"
                      WHERE consumer_key = ?
                        AND (userid = ? OR userid IS NULL)
                      ")Command was:
                      DELETE FROM "oauth_server_registry"
                      WHERE consumer_key = ?
                        AND (userid = ? OR userid IS NULL)
                      and values was 
(0:96a91f9a865716feca5030a456f7154505c131e2d,1:45349)
  Call stack (most recent first):

      log_message("Failed to get a recordset: postgres8 error: [-1: E...", 8, 
true, true) at /var/www/var/www/mahara/htdocs/lib/errors.php:95
      log_warn("Failed to get a recordset: postgres8 error: [-1: E...") at 
/var/www/var/www/mahara/htdocs/lib/errors.php:858
      SQLException->__construct("Failed to get a recordset: postgres8 error: 
[-1: E...") at /var/www/var/www/mahara/htdocs/lib/dml.php:1025
      delete_records_sql(" DELETE FROM "oauth_server_reg...", array(size 2)) at 
/var/www/var/www/mahara/htdocs/webservice/libs/oauth-php/store/OAuthStoreMahara.php:156
      
OAuthStoreMahara->deleteServer("96a91f9a865716feca5030a456f7154505c131e2d", 
"45349", true) at 
/var/www/var/www/mahara/htdocs/webservice/admin/oauthv1sregister.php:120
      webservices_server_submit(object(Pieform), array(size 4)) at 
/var/www/var/www/mahara/htdocs/lib/pieforms/pieform.php:542
      Pieform->__construct(array(size 7)) at 
/var/www/var/www/mahara/htdocs/lib/pieforms/pieform.php:164
      Pieform::process(array(size 7)) at 
/var/www/var/www/mahara/htdocs/lib/mahara.php:5258
      pieform(array(size 7)) at 
/var/www/var/www/mahara/htdocs/webservice/admin/oauthv1sregister.php:469
      webservice_server_list_form(array(size 9), array(size 3)) at 
/var/www/var/www/mahara/htdocs/webservice/admin/oauthv1sregister.php:58

  [WAR] ff (lib/dml.php:1025) Failed to get a recordset: postgres8 error: [-1: 
ERROR:  update or delete on table "oauth_server_registry" violates foreign key 
constraint "ltiasse_oau_fk" on table "lti_assessment"
  DETAIL:  Key (id)=(1) is still referenced from table "lti_assessment".] in 
EXECUTE("
                      DELETE FROM "oauth_server_registry"
                      WHERE consumer_key = ?
                        AND (userid = ? OR userid IS NULL)
                      ")Command was:
                      DELETE FROM "oauth_server_registry"
                      WHERE consumer_key = ?
                        AND (userid = ? OR userid IS NULL)
                      and values was 
(0:96a91f9a865716feca5030a456f7154505c131e2d,1:45349)
  Call stack (most recent first):

      delete_records_sql(" DELETE FROM "oauth_server_reg...", array(size 2)) at 
/var/www/var/www/mahara/htdocs/webservice/libs/oauth-php/store/OAuthStoreMahara.php:156
      
OAuthStoreMahara->deleteServer("96a91f9a865716feca5030a456f7154505c131e2d", 
"45349", true) at 
/var/www/var/www/mahara/htdocs/webservice/admin/oauthv1sregister.php:120
      webservices_server_submit(object(Pieform), array(size 4)) at 
/var/www/var/www/mahara/htdocs/lib/pieforms/pieform.php:542
      Pieform->__construct(array(size 7)) at 
/var/www/var/www/mahara/htdocs/lib/pieforms/pieform.php:164
      Pieform::process(array(size 7)) at 
/var/www/var/www/mahara/htdocs/lib/mahara.php:5258
      pieform(array(size 7)) at 
/var/www/var/www/mahara/htdocs/webservice/admin/oauthv1sregister.php:469
      webservice_server_list_form(array(size 9), array(size 3)) at 
/var/www/var/www/mahara/htdocs/webservice/admin/oauthv1sregister.php:58

  The delete function needs to also remove records from the
  lti_assessment table due to the foreign key constraint.

  But, I'm not sure if that is the correct way to go. If there are
  assignments, do we want to keep them and perhaps disable the external
  app?

  To delete, add the following to
  /htdocs/webservice/admin.oauthv1sregister.php at line 120:

  delete_records_sql('DELETE FROM {lti_assessment} WHERE oauthserver IN
  (SELECT id FROM {oauth_server_registry} WHERE consumer_key = ?)',
  array($dbserver->consumer_key));

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

_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to