You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
10
10
### Added
11
11
- Code snippet in `GenericmessageCommand` to keep obsolete service message system commands working.
12
12
- Static boolean property `SystemCommand::$execute_deprecated` (must be assigned before handling the request) to try and execute any deprecated system command.
13
+
- Improved MySQL DB index for `message` table, making the clean much faster on bigger databases. (Thanks to @damianperez)
14
+
-`/cleanup` command now supports dry run which simply outputs all queries that would be run.
13
15
### Changed
14
16
- Small readme and code fixes / simplifications.
15
17
- Upgrade PHPUnit to 8.x and PHPCS to 3.5. For tests now minimum PHP version is 7.2.
@@ -23,6 +25,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
23
25
- Boolean value for Polls gets saved correctly in MySQL DB.
24
26
- Correctly use `Request::answerInlineQuery` in `InlineQuery::answer`.
$data['text'] = 'Cleaning up tables:' . PHP_EOL . implode(PHP_EOL, $infos);
388
+
$data = [
389
+
'chat_id' => $message->getFrom()->getId(),
390
+
'parse_mode' => 'Markdown',
391
+
];
392
392
393
+
$data['text'] = 'Cleaning up tables:' . PHP_EOL . implode(PHP_EOL, $infos);
393
394
Request::sendMessage($data);
394
395
395
396
$rows = 0;
@@ -398,27 +399,30 @@ public function execute()
398
399
$pdo->beginTransaction();
399
400
400
401
foreach ($queriesas$query) {
401
-
if ($dbq = $pdo->query($query)) {
402
+
// Delete in chunks to not block / improve speed on big tables.
403
+
$query .= ' LIMIT 10000';
404
+
while ($dbq = $pdo->query($query)) {
405
+
if ($dbq->rowCount() === 0) {
406
+
continue2;
407
+
}
402
408
$rows += $dbq->rowCount();
403
-
} else {
404
-
TelegramLog::error('Error while executing query: ' . $query);
405
409
}
410
+
411
+
TelegramLog::error('Error while executing query: ' . $query);
406
412
}
407
413
408
-
$pdo->commit(); // commit changes to the database and end transaction
409
-
} catch (PDOException$e) {
410
-
$pdo->rollBack(); // rollback changes on exception (useful if you want to track down error - you can't replicate it when some of the data is already deleted...)
414
+
// commit changes to the database and end transaction
0 commit comments