ycom icon indicating copy to clipboard operation
ycom copied to clipboard

Fix foreign key constraint violation during ycom addon uninstall

Open Copilot opened this issue 7 months ago • 2 comments

This PR fixes a foreign key constraint violation that prevents the ycom addon from being uninstalled properly.

Problem

When attempting to uninstall the ycom addon, users encounter this error:

SQL error: Error while executing statement "DROP TABLE `rex_ycom_user`" using params []! 
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails

Root Cause

The auth plugin creates a rex_ycom_user_token table with a foreign key constraint to rex_ycom_user:

  • rex_ycom_user_token.user_idrex_ycom_user.id (CASCADE)
  • rex_ycom_user_session.user_idrex_ycom_user.id (CASCADE)

However, the auth plugin lacks an uninstall.php script, so the rex_ycom_user_token table is never cleaned up during addon uninstallation. When the main uninstall script tries to drop rex_ycom_user, MySQL/MariaDB prevents it due to the existing foreign key constraints.

Solution

This fix adds the missing cleanup for the rex_ycom_user_token table to the main uninstall.php script and ensures proper table dropping order:

  1. Clean up YForm metadata for both rex_ycom_user and rex_ycom_user_token tables
  2. Remove article columns
  3. Drop dependent tables first: rex_ycom_user_session and rex_ycom_user_token
  4. Finally drop rex_ycom_user table safely

The changes are minimal and surgical - only adding the missing table cleanup without modifying any existing logic or removing working code.

Fixes #519.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/XiKpia /usr/bin/composer install --dev (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Aug 04 '25 20:08 Copilot