[Fix] LegalDocuments #0048204: Avoid MySQL error 1093 when deleting documents - #11942
Open
fhelfer wants to merge 1 commit into
Open
[Fix] LegalDocuments #0048204: Avoid MySQL error 1093 when deleting documents#11942fhelfer wants to merge 1 commit into
fhelfer wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Documents that are added via Terms of Service or Declaration of Data Protection cannot be deleted afterwards. The request fails with an internal error:
ilDatabaseException SQLSTATE[HY000]: General error: 1093 You can't specify target table 'ldoc_documents' for update in FROM clause
DELETE FROM ldoc_documents WHERE id = 9 AND EXISTS ( SELECT 1 FROM ldoc_documents AS t29 WHERE t29.id = ldoc_documents.id AND t29.provider = 'dpro' )
provider = 'dpro'is Data Protection; Terms of Service uses'tos'. Both hit the same delete path.Why it is easy to miss
The query is generated in
DatabaseDocumentRepository::deleteEntry(). It appendsexists(), which always subselectsldoc_documents.On MariaDB this DELETE is legal. On Oracle MySQL 8 it is not (error 1093). ILIAS 10 still supports MySQL > 8.0.21; the reference system is MariaDB, so local tests often never see the failure.
The same
deleteEntry()implementation is still present on release_11 and trunk. Those branches still support MySQL (8.0.x / 8.4.x). Error 1093 is unchanged there, so the fix should be applied to 10, 11, and trunk.Mantis: https://mantis.ilias.de/view.php?id=48204
Fix
When deleting from
ldoc_documents, restrict withprovider = ...instead ofEXISTSon the same table: