Module: appdb Branch: master Commit: 37f72a60b0231e0478aba1f4574f9dcc326959b6 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=37f72a60b0231e0478aba1f45...
Author: Rosanne DiMesio dimesio@earthlink.net Date: Tue May 30 10:20:12 2017 -0500
admin.php: add functions to delete orphan versions and comments
The cron cleanup script identifies orphan versions but does not delete them, and admins have had no way to delete them. Bug 26958 stayed open for 6 years because admins had no way to delete orphan comments.
Signed-off-by: Rosanne DiMesio dimesio@earthlink.net Signed-off-by: Jeremy Newman jnewman@codeweavers.com
---
admin.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/admin.php b/admin.php index 90d1fc8..f38924d 100644 --- a/admin.php +++ b/admin.php @@ -203,11 +203,30 @@ function fixNoteLinks()
}
+function deleteOrphanComments() +{ + $sQuery = "DELETE FROM appComments WHERE NOT EXISTS( SELECT appVersion.versionId FROM appVersion"; + $sQuery.= " WHERE appVersion.versionId = appComments.versionId )"; + $hResult = query_parameters($sQuery); + + echo "Deleted ".query_affected_rows()." orphan comments.<br>"; +} + +function deleteOrphanVersions() +{ + $sQuery = "DELETE FROM appVersion WHERE appId = 0 and state != 'deleted'"; + $hResult = query_parameters($sQuery); + + echo "Deleted ".query_affected_rows()." orphan versions.<br>"; +} + function showChoices() { echo '<a href="admin.php?sAction=fixNoteLinks">Fix/Show note links</a><br />'; echo '<a href="admin.php?sAction=updateAppMaintainerStates">Update application maintainer states</a><br />'; echo '<a href="admin.php?sAction=updateVersionMaintainerStates">Update version maintainer states</a><br />'; + echo '<a href="admin.php?sAction=deleteOrphanComments">Delete Orphan Comments</a><br>'; + echo '<a href="admin.php?sAction=deleteOrphanVersions">Delete Orphan Versions</a><br>'; }
switch(getInput('sAction', $aClean)) @@ -223,7 +242,15 @@ switch(getInput('sAction', $aClean)) case 'fixNoteLinks': fixNoteLinks(); break; - + + case 'deleteOrphanComments': + deleteOrphanComments(); + break; + + case 'deleteOrphanVersions': + deleteOrphanVersions(); + break; + default: showChoices(); break;