[Rt-commit] rt branch, 4.2/minimal-oracle-ticket-subject-undef-fix, created. rt-4.2.14-43-gfc961da40
? sunnavy
sunnavy at bestpractical.com
Mon Mar 26 13:44:59 EDT 2018
The branch, 4.2/minimal-oracle-ticket-subject-undef-fix has been created
at fc961da40af8f43319ec78e5c6fcf9796bfe22bd (commit)
- Log -----------------------------------------------------------------
commit fc961da40af8f43319ec78e5c6fcf9796bfe22bd
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Mar 27 01:01:39 2018 +0800
Minimize the change of converting not defined Subject to '' for Oracle
Converting not defined Subject to '' is not always right, for 2 reasons:
* For db types besides Oracle, both undef and '' are supported and the
values are different at least at SQL level.
* Subject could be resonable undef.
If current user has no ShowTicket right, then undef is more correct than
''.
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 7e2d7fe12..f00d9fda9 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1137,12 +1137,21 @@ sub QueueObj {
return ($self->{_queue_obj});
}
-# Oracle treats empty strings as NULL, so it returns undef for empty subjects,
-# which could cause uninitialized warnings.
-
sub Subject {
my $self = shift;
- return $self->_Value( 'Subject' ) // '';
+
+ my $subject = $self->_Value( 'Subject' );
+ return $subject if defined $subject;
+
+ if ( RT->Config->Get( 'DatabaseType' ) eq 'Oracle' && $self->CurrentUserHasRight( 'ShowTicket' ) ) {
+
+ # Oracle treats empty strings as NULL, so it returns undef for empty subjects.
+ # Since '' is the default Subject value, returning '' is more correct.
+ return '';
+ }
+ else {
+ return undef;
+ }
}
sub SetSubject {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list