Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: Check state of tables when we remove a layer which has used before #549

Open
1 task done
Gustry opened this issue Jan 24, 2024 · 1 comment
Open
1 task done
Assignees
Labels

Comments

@Gustry
Copy link
Member

Gustry commented Jan 24, 2024

What is the bug?

It looks easy now to have a broken configuration in Lizmap when we remove a layer from QGIS.

Maye the signel is not detected and the cleaning is not done

Versions, safeguards, checks summary etc

Git master branch

Check Lizmap plugin

  • I have done the step just before in the Lizmap QGIS desktop plugin before opening this ticket. Otherwise, my ticket is not considered valid and might get closed.
@Gustry Gustry added the Bug label Jan 24, 2024
@Gustry Gustry self-assigned this Jan 24, 2024
@sudhanshu112233shukla
Copy link

Hi, I'd like to work on this issue. It seems that when a layer is removed, related tables might still reference it, potentially causing errors or unexpected behavior.

Could you clarify:

Should the system automatically clean up the tables, or should users be notified?
Are there specific database tables or code sections handling these layer relationships?
I’d be happy to investigate and suggest a fix. Let me know your thoughts!

We can use it if you suggest
SQL Check Before Removing a Layer
SELECT * FROM layer_table WHERE layer_id = 'LAYER_ID';

PHP: Remove References Before Deleting a Layer
function deleteLayer($layerId) {
// Remove references first
$db->query("DELETE FROM related_table WHERE layer_id = ?", [$layerId]);
// Now delete the layer
$db->query("DELETE FROM layers WHERE id = ?", [$layerId]);
}

JavaScript: Warn User Before Deleting a Layer
function confirmLayerDeletion(layerId) {
if (confirm("This layer is linked to other tables. Are you sure you want to remove it?")) {
deleteLayer(layerId);
}
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants