Ensure to only delete data of a valid contact
This commit is contained in:
parent
22cae5aaf2
commit
963374bb3e
1 changed files with 20 additions and 18 deletions
|
@ -68,27 +68,29 @@ class ExpireAndRemoveUsers
|
||||||
Logger::warning('Error deleting user photos', ['errno' => DBA::errorNo(), 'errmsg' => DBA::errorMessage()]);
|
Logger::warning('Error deleting user photos', ['errno' => DBA::errorNo(), 'errmsg' => DBA::errorMessage()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = DBA::delete('post-tag', ['cid' => $pcid]);
|
if (!empty($pcid)) {
|
||||||
if ($result) {
|
$result = DBA::delete('post-tag', ['cid' => $pcid]);
|
||||||
Logger::debug('Deleted post-tag entries', ['result' => $result, 'rows' => DBA::affectedRows()]);
|
if ($result) {
|
||||||
} else {
|
Logger::debug('Deleted post-tag entries', ['result' => $result, 'rows' => DBA::affectedRows()]);
|
||||||
Logger::warning('Error deleting post-tag entries', ['errno' => DBA::errorNo(), 'errmsg' => DBA::errorMessage()]);
|
} else {
|
||||||
}
|
Logger::warning('Error deleting post-tag entries', ['errno' => DBA::errorNo(), 'errmsg' => DBA::errorMessage()]);
|
||||||
|
}
|
||||||
|
|
||||||
$tables = ['post', 'post-user', 'post-thread', 'post-thread-user'];
|
$tables = ['post', 'post-user', 'post-thread', 'post-thread-user'];
|
||||||
|
|
||||||
if (DBStructure::existsTable('item')) {
|
if (DBStructure::existsTable('item')) {
|
||||||
$tables[] = 'item';
|
$tables[] = 'item';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all entries with the public contact in post related tables
|
// Delete all entries with the public contact in post related tables
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
foreach (['owner-id', 'author-id', 'causer-id'] as $field) {
|
foreach (['owner-id', 'author-id', 'causer-id'] as $field) {
|
||||||
$result = DBA::delete($table, [$field => $pcid]);
|
$result = DBA::delete($table, [$field => $pcid]);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
Logger::debug('Deleted entries', ['table' => $table, 'field' => $field, 'result' => $result, 'rows' => DBA::affectedRows()]);
|
Logger::debug('Deleted entries', ['table' => $table, 'field' => $field, 'result' => $result, 'rows' => DBA::affectedRows()]);
|
||||||
} else {
|
} else {
|
||||||
Logger::warning('Error deleting entries', ['table' => $table, 'field' => $field, 'errno' => DBA::errorNo(), 'errmsg' => DBA::errorMessage()]);
|
Logger::warning('Error deleting entries', ['table' => $table, 'field' => $field, 'errno' => DBA::errorNo(), 'errmsg' => DBA::errorMessage()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue