Store epoch to correct entry, fix uninitialized variable

This commit is contained in:
Jonathan Flueren 2021-10-13 16:16:23 +02:00 committed by thrillfall
parent 001a333367
commit 6dd54198f6
1 changed files with 3 additions and 1 deletions

View File

@ -32,11 +32,13 @@ class TimestampMigration implements \OCP\Migration\IRepairStep
$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 = null;
foreach ($timestamps as $timestamp) { foreach ($timestamps as $timestamp) {
$timestampEpoch = (new DateTime($timestamp["timestamp"]))->format("U"); $timestampEpoch = (new DateTime($timestamp["timestamp"]))->format("U");
$sql = 'UPDATE `*PREFIX*gpodder_episode_action` ' $sql = 'UPDATE `*PREFIX*gpodder_episode_action` '
. 'SET `timestamp_epoch` = ' . $timestampEpoch . ' ' . 'SET `timestamp_epoch` = ' . $timestampEpoch . ' '
. 'WHERE `timestamp_epoch` = 0'; . 'WHERE `id` = ' . $timestamp["id"];
$result = $this->db->executeUpdate($sql); $result = $this->db->executeUpdate($sql);