Remove usage of safe-library for compability

This commit is contained in:
JonOfUs 2024-09-23 17:19:34 +02:00 committed by Jonathan Flueren
parent df17366e0f
commit e8611c6e99

View File

@ -5,7 +5,7 @@ namespace OCA\GPodderSync\Migration;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\Migration\IOutput; use OCP\Migration\IOutput;
use Safe\DateTime; use DateTime;
class TimestampMigration implements \OCP\Migration\IRepairStep class TimestampMigration implements \OCP\Migration\IRepairStep
{ {
@ -29,22 +29,27 @@ class TimestampMigration implements \OCP\Migration\IRepairStep
*/ */
public function run(IOutput $output) public function run(IOutput $output)
{ {
$queryTimestamps = 'SELECT id, timestamp FROM `*PREFIX*gpodder_episode_action` WHERE timestamp_epoch = 0'; $queryTimestamps =
"SELECT id, timestamp FROM `*PREFIX*gpodder_episode_action` WHERE timestamp_epoch = 0";
$timestamps = $this->db->executeQuery($queryTimestamps)->fetchAll(); $timestamps = $this->db->executeQuery($queryTimestamps)->fetchAll();
$result = 0; $result = 0;
foreach ($timestamps as $timestamp) { foreach ($timestamps as $timestamp) {
$timestampEpoch = (new DateTime($timestamp["timestamp"]))->format("U"); $timestampEpoch = (new DateTime($timestamp["timestamp"]))->format(
$sql = 'UPDATE `*PREFIX*gpodder_episode_action` ' "U"
. 'SET `timestamp_epoch` = ' . $timestampEpoch . ' ' );
. 'WHERE `id` = ' . $timestamp["id"]; $sql =
"UPDATE `*PREFIX*gpodder_episode_action` " .
"SET `timestamp_epoch` = " .
$timestampEpoch .
" " .
"WHERE `id` = " .
$timestamp["id"];
$result += $this->db->executeUpdate($sql); $result += $this->db->executeUpdate($sql);
} }
return $result; return $result;
} }
} }