From 6dcc87b1adeb71a9c83cafa95a95a80c50b62092 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 18 May 2011 00:23:35 +0100
Subject: Accidentally committed too early Revert "Allow item links to be
deleted even when other deletes and purges are disabled."
This reverts commit 491279f99afc65860d44765ee7829c7dd5e4e38e.
---
OpenSim/Data/IXInventoryData.cs | 29 ------------------
OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs | 35 ++++++++--------------
OpenSim/Data/MSSQL/MSSQLXInventoryData.cs | 10 -------
OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 27 ++++-------------
OpenSim/Data/MySQL/MySQLXInventoryData.cs | 10 -------
OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs | 28 ++++-------------
OpenSim/Data/SQLite/SQLiteXInventoryData.cs | 10 -------
.../Services/InventoryService/XInventoryService.cs | 30 ++++---------------
8 files changed, 30 insertions(+), 149 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
index 85a5c08..d85a7ef 100644
--- a/OpenSim/Data/IXInventoryData.cs
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -74,38 +74,9 @@ namespace OpenSim.Data
bool StoreFolder(XInventoryFolder folder);
bool StoreItem(XInventoryItem item);
- ///
- /// Delete folders where field == val
- ///
- ///
- ///
- /// true if the delete was successful, false if it was not
bool DeleteFolders(string field, string val);
-
- ///
- /// Delete folders where field1 == val1, field2 == val2...
- ///
- ///
- ///
- /// true if the delete was successful, false if it was not
- bool DeleteFolders(string[] fields, string[] vals);
-
- ///
- /// Delete items where field == val
- ///
- ///
- ///
- /// true if the delete was successful, false if it was not
bool DeleteItems(string field, string val);
- ///
- /// Delete items where field1 == val1, field2 == val2...
- ///
- ///
- ///
- /// true if the delete was successful, false if it was not
- bool DeleteItems(string[] fields, string[] vals);
-
bool MoveItem(string id, string newParent);
XInventoryItem[] GetActiveGestures(UUID principalID);
int GetAssetPermissions(UUID principalID, UUID assetID);
diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
index 317afac..f5492b3 100644
--- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
@@ -335,35 +335,24 @@ namespace OpenSim.Data.MSSQL
}
}
- public virtual bool Delete(string field, string key)
+ public virtual bool Delete(string field, string val)
{
- return Delete(new string[] { field }, new string[] { key });
- }
-
- public virtual bool Delete(string[] fields, string[] keys)
- {
- if (fields.Length != keys.Length)
- return false;
-
- List terms = new List();
-
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
using (SqlCommand cmd = new SqlCommand())
{
- for (int i = 0; i < fields.Length; i++)
- {
- cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
- terms.Add("[" + fields[i] + "] = @" + fields[i]);
- }
-
- string where = String.Join(" AND ", terms.ToArray());
-
- string query = String.Format("DELETE * FROM {0} WHERE {1}", m_Realm, where);
-
+ string deleteCommand = String.Format("DELETE FROM {0} WHERE [{1}] = @{1}", m_Realm, field);
+ cmd.CommandText = deleteCommand;
+
+ cmd.Parameters.Add(m_database.CreateParameter(field, val));
cmd.Connection = conn;
- cmd.CommandText = query;
conn.Open();
- return cmd.ExecuteNonQuery() > 0;
+
+ if (cmd.ExecuteNonQuery() > 0)
+ {
+ //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand);
+ return true;
+ }
+ return false;
}
}
}
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 01689a4..5bc4fe4 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -79,21 +79,11 @@ namespace OpenSim.Data.MSSQL
return m_Folders.Delete(field, val);
}
- public bool DeleteFolders(string[] fields, string[] vals)
- {
- return m_Folders.Delete(fields, vals);
- }
-
public bool DeleteItems(string field, string val)
{
return m_Items.Delete(field, val);
}
- public bool DeleteItems(string[] fields, string[] vals)
- {
- return m_Items.Delete(fields, vals);
- }
-
public bool MoveItem(string id, string newParent)
{
return m_Items.MoveItem(id, newParent);
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 754cf72..cfffbd8 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -264,33 +264,18 @@ namespace OpenSim.Data.MySQL
}
}
- public virtual bool Delete(string field, string key)
+ public virtual bool Delete(string field, string val)
{
- return Delete(new string[] { field }, new string[] { key });
- }
-
- public virtual bool Delete(string[] fields, string[] keys)
- {
- if (fields.Length != keys.Length)
- return false;
-
- List terms = new List();
-
using (MySqlCommand cmd = new MySqlCommand())
{
- for (int i = 0 ; i < fields.Length ; i++)
- {
- cmd.Parameters.AddWithValue(fields[i], keys[i]);
- terms.Add("`" + fields[i] + "` = ?" + fields[i]);
- }
-
- string where = String.Join(" and ", terms.ToArray());
- string query = String.Format("delete from {0} where {1}", m_Realm, where);
+ cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
+ cmd.Parameters.AddWithValue(field, val);
- cmd.CommandText = query;
+ if (ExecuteNonQuery(cmd) > 0)
+ return true;
- return ExecuteNonQuery(cmd) > 0;
+ return false;
}
}
}
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index caf18a4..481da49 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -85,21 +85,11 @@ namespace OpenSim.Data.MySQL
return m_Folders.Delete(field, val);
}
- public bool DeleteFolders(string[] fields, string[] vals)
- {
- return m_Folders.Delete(fields, vals);
- }
-
public bool DeleteItems(string field, string val)
{
return m_Items.Delete(field, val);
}
- public bool DeleteItems(string[] fields, string[] vals)
- {
- return m_Items.Delete(fields, vals);
- }
-
public bool MoveItem(string id, string newParent)
{
return m_Items.MoveItem(id, newParent);
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 3fb2d3f..0d7b001 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -258,33 +258,17 @@ namespace OpenSim.Data.SQLite
return false;
}
- public virtual bool Delete(string field, string key)
+ public bool Delete(string field, string val)
{
- return Delete(new string[] { field }, new string[] { key });
- }
-
- public bool Delete(string[] fields, string[] keys)
- {
- if (fields.Length != keys.Length)
- return false;
-
- List terms = new List();
-
SqliteCommand cmd = new SqliteCommand();
- for (int i = 0 ; i < fields.Length ; i++)
- {
- cmd.Parameters.Add(new SqliteParameter(":" + fields[i], keys[i]));
- terms.Add("`" + fields[i] + "` = :" + fields[i]);
- }
-
- string where = String.Join(" and ", terms.ToArray());
-
- string query = String.Format("delete * from {0} where {1}", m_Realm, where);
+ cmd.CommandText = String.Format("delete from {0} where `{1}` = :{1}", m_Realm, field);
+ cmd.Parameters.Add(new SqliteParameter(field, val));
- cmd.CommandText = query;
+ if (ExecuteNonQuery(cmd, m_Connection) > 0)
+ return true;
- return ExecuteNonQuery(cmd, m_Connection) > 0;
+ return false;
}
}
}
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 02edc30..ccbd86e 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -91,21 +91,11 @@ namespace OpenSim.Data.SQLite
return m_Folders.Delete(field, val);
}
- public bool DeleteFolders(string[] fields, string[] vals)
- {
- return m_Folders.Delete(fields, vals);
- }
-
public bool DeleteItems(string field, string val)
{
return m_Items.Delete(field, val);
}
- public bool DeleteItems(string[] fields, string[] vals)
- {
- return m_Items.Delete(fields, vals);
- }
-
public bool MoveItem(string id, string newParent)
{
return m_Items.MoveItem(id, newParent);
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index a094a02..0af35c8 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -411,30 +411,12 @@ namespace OpenSim.Services.InventoryService
public virtual bool DeleteItems(UUID principalID, List itemIDs)
{
if (!m_AllowDelete)
- {
- // We must still allow links and links to folders to be deleted, otherwise they will build up
- // in the player's inventory until they can no longer log in. Deletions of links due to code bugs or
- // similar is inconvenient but on a par with accidental movement of items. The original item is never
- // touched.
- foreach (UUID id in itemIDs)
- {
- if (!m_Database.DeleteItems(
- new string[] { "inventoryID", "assetType" },
- new string[] { id.ToString(), ((sbyte)AssetType.Link).ToString() }));
- {
- m_Database.DeleteItems(
- new string[] { "inventoryID", "assetType" },
- new string[] { id.ToString(), ((sbyte)AssetType.LinkFolder).ToString() });
- }
- }
- }
- else
- {
- // Just use the ID... *facepalms*
- //
- foreach (UUID id in itemIDs)
- m_Database.DeleteItems("inventoryID", id.ToString());
- }
+ return false;
+
+ // Just use the ID... *facepalms*
+ //
+ foreach (UUID id in itemIDs)
+ m_Database.DeleteItems("inventoryID", id.ToString());
return true;
}
--
cgit v1.1