-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix exception when generating changeRequest XML where the oldProperty is null and newProperty is a DateTime #380
base: v7
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
if ($oldPropertyValue !== $newPropertyValue) { | ||
$dirtyProperties[$propertyName]['old'] = $oldPropertyValue; | ||
$dirtyProperties[$propertyName]['new'] = $newPropertyValue; | ||
} | ||
} else { | ||
if (get_class($oldPropertyValue) === 'DateTime') { | ||
if (($oldPropertyValue != null && get_class($oldPropertyValue) === 'DateTime') || ($newPropertyValue != null && get_class($newPropertyValue) === 'DateTime')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use type safe comparisons ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added your suggestions, but i left out the |
||
/** @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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition in line 255 only checks if at least one of the two propertyValues is a DateTime. Therefore either one of them could still be |
||
$newTimestamp = $newPropertyValue != null ? $newPropertyValue->getTimestamp() : 0; | ||
|
||
if ($oldTimestamp !== $newTimestamp) { | ||
$dirtyProperties[$propertyName]['old'] = $oldTimestamp; | ||
$dirtyProperties[$propertyName]['new'] = $newTimestamp; | ||
} | ||
} else { | ||
$titlesOld = ObjectUtility::implodeObjectStorageOnProperty($oldPropertyValue); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.