Skip to content

Commit

Permalink
Fix EZP-30817: ezplatform:timestamps:to-utc command updates wrong fie…
Browse files Browse the repository at this point in the history
…ld versions (#2724)
  • Loading branch information
blankse authored and andrerom committed Aug 6, 2019
1 parent 05c607d commit 40aa84c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected function processTimestamps($offset, $limit, $output)

//failsafe for int field limitation (dates/datetimes after 01/19/2038 @ 4:14am (UTC))
if ($newTimestamp <= self::MAX_TIMESTAMP_VALUE && !$this->dryRun) {
$this->updateTimestampToUTC($timestampBasedField['id'], $newTimestamp);
$this->updateTimestampToUTC($timestampBasedField['id'], $timestampBasedField['version'], $newTimestamp);
}
++$this->done;
}
Expand All @@ -308,7 +308,7 @@ protected function getTimestampBasedFields($offset, $limit)
{
$query = $this->connection->createQueryBuilder();
$query
->select('a.id, a.data_int')
->select('a.id, a.version, a.data_int')
->from('ezcontentobject_attribute', 'a')
->join('a', 'ezcontentobject_version', 'v', 'a.contentobject_id = v.contentobject_id')
->where(
Expand Down Expand Up @@ -463,10 +463,12 @@ protected function getProgressBar($maxSteps, OutputInterface $output)

/**
* @param int $contentAttributeId
* @param int $contentAttributeVersion
* @param int $newTimestamp
*/
protected function updateTimestampToUTC(
$contentAttributeId,
$contentAttributeVersion,
$newTimestamp
) {
$query = $this->connection->createQueryBuilder();
Expand All @@ -475,7 +477,9 @@ protected function updateTimestampToUTC(
->set('a.data_int', $newTimestamp)
->set('a.sort_key_int', $newTimestamp)
->where('a.id = :id')
->setParameter(':id', $contentAttributeId);
->andWhere('a.version = :version')
->setParameter(':id', $contentAttributeId)
->setParameter(':version', $contentAttributeVersion);

$query->execute();
}
Expand Down

0 comments on commit 40aa84c

Please sign in to comment.