Skip to content

Commit

Permalink
Merge pull request #13268 from craftcms/fix-rev-params
Browse files Browse the repository at this point in the history
Account for null Asset::dateModified
  • Loading branch information
brandonkelly authored Jun 12, 2023
2 parents 40ada56 + 038030a commit 4f654a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fixed a bug where `craft\db\Query::collect()` was returning a `craft\elements\ElementCollection` instance.
- Fixed a SQL error that could occur when upgrading to Craft 4 if any database tables had foreign keys to `entryversions` or other now-unused tables that are removed during the upgrade.
- Fixed a bug where the `users/save-user` action wasn’t including user details in successful responses. ([#13267](https://github.com/craftcms/cms/issues/13267))
- Fixed a PHP error that occurred if an asset without a `dateModified` value was passed to `craft\helpers\Assets::revParams()`. ([#13268](https://github.com/craftcms/cms/pull/13268))

## 4.4.13 - 2023-05-24

Expand Down
16 changes: 11 additions & 5 deletions src/helpers/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,22 @@ public static function generateUrl(BaseFsInterface $fs, Asset $asset, ?string $u
*/
public static function revParams(Asset $asset, ?DateTime $dateUpdated = null): array
{
/** @var DateTime $dateModified */
$dateModified = max($asset->dateModified, $dateUpdated ?? null);
$v = $dateModified->getTimestamp();
$v = [];

$dateModified = max($asset->dateModified, $dateUpdated);
if ($dateModified) {
$v[] = $dateModified->getTimestamp();
}

if ($asset->getHasFocalPoint()) {
$fp = $asset->getFocalPoint();
$v .= ",{$fp['x']},{$fp['y']}";
$v[] = $fp['x'];
$v[] = $fp['y'];
}

return compact('v');
return array_filter([
'v' => implode(',', $v),
]);
}

/**
Expand Down

0 comments on commit 4f654a2

Please sign in to comment.