[AppDB] admin.php: add functions to delete orphan versions and comments
Rosanne DiMesio
dimesio at earthlink.net
Tue May 30 10:20:12 CDT 2017
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 at earthlink.net>
---
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;
--
2.12.0
More information about the wine-patches
mailing list