Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Classes/Utility/UserUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,22 @@ public static function getDirtyPropertiesFromUser(User $changedObject)
&& !in_array($propertyName, $ignoreProperties)
) {
$newPropertyValue = $changedObject->{'get' . ucfirst($propertyName)}();
if (!is_object($oldPropertyValue) || !is_object($newPropertyValue)) {
if (!is_object($oldPropertyValue) && !is_object($newPropertyValue)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move the condition of the next line into this condition.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That condition should probably stay as is, otherwise the else part starting in line 267 is entered when it shouldn't be.

if ($oldPropertyValue !== $newPropertyValue) {
$dirtyProperties[$propertyName]['old'] = $oldPropertyValue;
$dirtyProperties[$propertyName]['new'] = $newPropertyValue;
}
} else {
if (get_class($oldPropertyValue) === 'DateTime') {
if (($oldPropertyValue !== null && $oldPropertyValue instanceof \DateTime) || ($newPropertyValue !== null && $newPropertyValue instanceof \DateTime)) {
/** @var $oldPropertyValue \DateTime */
/** @var $newPropertyValue \DateTime */
if ($oldPropertyValue->getTimestamp() !== $newPropertyValue->getTimestamp()) {
$dirtyProperties[$propertyName]['old'] = $oldPropertyValue->getTimestamp();
$dirtyProperties[$propertyName]['new'] = $newPropertyValue->getTimestamp();

$oldTimestamp = $oldPropertyValue !== null ? $oldPropertyValue->getTimestamp() : 0;
$newTimestamp = $newPropertyValue !== null ? $newPropertyValue->getTimestamp() : 0;

if ($oldTimestamp !== $newTimestamp) {
$dirtyProperties[$propertyName]['old'] = $oldTimestamp;
$dirtyProperties[$propertyName]['new'] = $newTimestamp;
}
} else {
$titlesOld = ObjectUtility::implodeObjectStorageOnProperty($oldPropertyValue);
Expand Down