Skip to content

Commit

Permalink
Merge pull request #2290 from RotherOSS/issue-#1777-uniitialized_value
Browse files Browse the repository at this point in the history
Issue #1777 uninitialized value
  • Loading branch information
bschmalhofer authored Apr 26, 2023
2 parents 500f5b3 + 483edca commit acf3df3
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 36 deletions.
6 changes: 5 additions & 1 deletion Kernel/GenericInterface/Operation/Ticket/TicketUpdate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,11 @@ sub _TicketUpdate {

# Convert article body to plain text, if HTML content was supplied. This is necessary since auto response code
# expects plain text content. Please see bug#13397 for more information.
if ( $Article->{ContentType} =~ /text\/html/i || $Article->{MimeType} =~ /text\/html/i ) {
if (
( $Article->{ContentType} // '' ) =~ /text\/html/i
|| ( $Article->{MimeType} // '' ) =~ /text\/html/i
)
{
$PlainBody = $Kernel::OM->Get('Kernel::System::HTMLUtils')->ToAscii(
String => $Article->{Body},
);
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Output/HTML/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ sub Header {
}

# run tool bar item modules
if ( $Self->{UserID} && $Self->{UserType} eq 'User' ) {
if ( $Self->{UserID} && ( $Self->{UserType} // '' ) eq 'User' ) {
my $ToolBarModule = $ConfigObject->Get('Frontend::ToolBarModule');
if ( $Param{ShowToolbarItems} && ref $ToolBarModule eq 'HASH' ) {

Expand Down Expand Up @@ -4777,7 +4777,7 @@ sub CustomerNavigationBar {
my %User = $Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerUserDataGet(
User => $Self->{UserLogin},
);
$Param{UserName} = "$User{UserFirstname} $User{UserLastname}";
$Param{UserName} = join ' ', ( $User{UserFirstname} // '' ), ( $User{UserLastname} // '' );

# generate avatar
if ( $ConfigObject->Get('Frontend::AvatarEngine') eq 'Gravatar' && $Self->{UserEmail} ) {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/System/CommunicationLog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ sub StatusGet {
Starts a log object of a given object type.
my $ObjectID = $CommunicationLogObject->ObjectLogStart(
ObjectType => 'Connection' # (required) Can be 'Connection' or 'Message'
ObjectLogType => 'Connection' # (required) Can be either 'Connection' or 'Message'
);
Returns:
Expand Down
3 changes: 2 additions & 1 deletion Kernel/System/Daemon/DaemonModules/BaseTaskWorker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ sub _CheckTaskParams {

for my $Needed (qw(TaskID Data)) {
if ( !$Param{$Needed} ) {
my $TaskName = $Param{TaskName} // '';
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed! - Task: $Param{TaskName}",
Message => "Need $Needed! - Task: $TaskName",
);

return;
Expand Down
1 change: 1 addition & 0 deletions Kernel/System/SysConfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,7 @@ sub ConfigurationXML2DB {

# Extract otobo_config Init attribute. E.g. 'Framework', 'Config'
my ($InitValue) = ${$ConfigFile} =~ m{<otobo_config.*?init="(.*?)"}gsmx;
$InitValue //= '';

# Check if InitValue is Valid.
if ( !defined $SettingsByInit{$InitValue} ) {
Expand Down
1 change: 1 addition & 0 deletions Kernel/System/UnitTest/Helper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ sub ConfigSettingChange {

if ($Valid) {
$ValueDump = $Kernel::OM->Get('Kernel::System::Main')->Dump($Value);
$ValueDump //= '';
$ValueDump =~ s/\$VAR1/$KeyDump/;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/Archive.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ else {
'Checksum file size in expected range (> 1KB && < 1MB)'
);

my $ErrorsFound;
my $ErrorsFound = 0;

# Verify MD5 digests in the checksum file.
LINE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ subtest
$SourceDir->stringify(),
);
}
$Stderr //= '';
note("stderr: $Stderr");

# exit code 0 indicates success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $ConfigObject->Set(
);

# check if openssl is located there
if ( !-e $OpenSSLBin ) {
if ( !$OpenSSLBin || !-e $OpenSSLBin ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/openssl' ) {
Expand All @@ -76,7 +76,7 @@ if ( !-e $OpenSSLBin ) {
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');

if ( !$SMIMEObject ) {
print STDERR "NOTICE: No SMIME support!\n";
diag "NOTICE: No SMIME support!\n";

if ( !-e $OpenSSLBin ) {
$Self->False(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $ConfigObject->Set(
);

# check if openssl is located there
if ( !-e $OpenSSLBin ) {
if ( !$OpenSSLBin || !-e $OpenSSLBin ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/openssl' ) {
Expand All @@ -76,7 +76,7 @@ if ( !-e $OpenSSLBin ) {
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');

if ( !$SMIMEObject ) {
print STDERR "NOTICE: No SMIME support!\n";
diag "NOTICE: No SMIME support!";

if ( !-e $OpenSSLBin ) {
$Self->False(
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/Console/Command/Maint/SMIME/KeysRefresh.t
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $ConfigObject->Set(
);

# check if OpenSSL is located there
if ( !-e $ConfigObject->Get('SMIME::Bin') ) {
if ( !$ConfigObject->Get('SMIME::Bin') || !-e $ConfigObject->Get('SMIME::Bin') ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/openssl' ) {
Expand Down
9 changes: 7 additions & 2 deletions scripts/test/GenericInterface/Operation/Ticket/TicketCreate.t
Original file line number Diff line number Diff line change
Expand Up @@ -4590,6 +4590,7 @@ for my $Test (@Tests) {
# TODO prevent failing test if enviroment on SaaS unit test system doesn't work.
if (
$Test->{SuccessCreate}
&& $RequesterResult->{ErrorMessage}
&& $RequesterResult->{ErrorMessage} eq
'faultcode: Server, faultstring: Attachment could not be created, please contact the system administrator'
)
Expand Down Expand Up @@ -4702,7 +4703,7 @@ for my $Test (@Tests) {
else {
my $ExpectedCustomerUserID = $Test->{RequestData}->{Ticket}->{CustomerUser};

if ( $Test->{Type} eq 'EmailCustomerUser' ) {
if ( $Test->{Type} && $Test->{Type} eq 'EmailCustomerUser' ) {
$ExpectedCustomerUserID = $CustomerRand;
}

Expand Down Expand Up @@ -4793,7 +4794,11 @@ for my $Test (@Tests) {
}
for my $DynamicField (@RequestedDynamicFields) {

if ( $DynamicField->{FieldType} eq 'Date' && $DynamicField->{Value} =~ m{ \A \d{4}-\d{2}-\d{2} \z }xms ) {
if (
$DynamicField->{FieldType} && $DynamicField->{FieldType} eq 'Date'
&& $DynamicField->{Value} && $DynamicField->{Value} =~ m{ \A \d{4}-\d{2}-\d{2} \z }xms
)
{
$DynamicField->{Value} .= ' 00:00:00';
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/test/GenericInterface/Operation/Ticket/TicketUpdate.t
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ for my $Test (@Tests) {

# TODO prevent failing test if enviroment on SaaS unit test system doesn't work.
if (
$RequesterResult->{ErrorMessage} eq
'faultcode: Server, faultstring: Attachment could not be created, please contact the system administrator'
$RequesterResult->{ErrorMessage}
&& $RequesterResult->{ErrorMessage} eq 'faultcode: Server, faultstring: Attachment could not be created, please contact the system administrator'
)
{
next TEST;
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/MailQueue/Send.t
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ for my $Test (@Tests) {
);

# Article Email Notifications Events.
if ( $ArticleTransmissionError->{Status} eq 'Failed' ) {
if ( $ArticleTransmissionError->{Status} && $ArticleTransmissionError->{Status} eq 'Failed' ) {
$CheckForQueueNotifications->(
ArticleID => $ArticleID,
);
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/PGP.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ConfigObject->Set(
);

# check if gpg is located there
if ( !-e $ConfigObject->Get('PGP::Bin') ) {
if ( !$ConfigObject->Get('PGP::Bin') || !-e $ConfigObject->Get('PGP::Bin') ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/gpg' ) {
Expand Down
15 changes: 10 additions & 5 deletions scripts/test/PostMaster.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# --

use v5.24;
use strict;
use warnings;
use utf8;

# Set up the test driver $Self when we are running as a standalone script.
use Kernel::System::UnitTest::RegisterDriver;
# core modules

our $Self;
# CPAN modules
use Test2::V0;

# OTOBO modules
use Kernel::System::UnitTest::RegisterDriver; # Set up $Kernel::OM and the test driver $main::Self
use Kernel::System::PostMaster;

our $Self;

$Kernel::OM->ObjectParamAdd(
'Kernel::System::UnitTest::Helper' => {
RestoreDatabase => 1,
Expand Down Expand Up @@ -1159,7 +1164,7 @@ for my $Type (qw(Config DB)) {
);
}
else {
print STDERR "\n Name: $Test->{Name} \n";
diag "Name: $Test->{Name}";
$ConfigObject->Set(
Key => 'PostMaster::PreFilterModule###' . $Test->{Name},
Value => {
Expand Down Expand Up @@ -1687,4 +1692,4 @@ $Self->Is(

# cleanup is done by RestoreDatabase

$Self->DoneTesting();
done_testing;
2 changes: 1 addition & 1 deletion scripts/test/PostMaster/Decrypt/PGP.t
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $ConfigObject->Set(
);

# Check if GPG is located there.
if ( !-e $ConfigObject->Get('PGP::Bin') ) {
if ( !$ConfigObject->Get('PGP::Bin') || !-e $ConfigObject->Get('PGP::Bin') ) {

if ( -e '/usr/bin/gpg' ) {
$ConfigObject->Set(
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/PostMaster/Decrypt/SMIME.t
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ if ( !-e $OpenSSLBin ) {
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');

if ( !$SMIMEObject ) {
print STDERR "NOTICE: No SMIME support!\n";
diag "NOTICE: No SMIME support!";

if ( !-e $OpenSSLBin ) {
$Self->False(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,7 @@ for my $Test (@Tests) {
$Article{$Attribute} //= '';
}

if ( $OrigTest->{Config}->{Config}->{$Attribute} eq '<OTOBO_AGENT_BODY[2]>' )
{
if ( $OrigTest->{Config}->{Config}->{$Attribute} eq '<OTOBO_AGENT_BODY[2]>' ) {
my @Count = ( $Article{$Attribute} =~ /the message text/g );
$Self->Is(
scalar @Count,
Expand All @@ -798,8 +797,7 @@ for my $Test (@Tests) {
);
}

if ( $OrigTest->{Config}->{Config}->{$Attribute} eq '<OTOBO_AGENT_SUBJECT[10]>' )
{
if ( $OrigTest->{Config}->{Config}->{$Attribute} eq '<OTOBO_AGENT_SUBJECT[10]>' ) {
$Self->Is(
$Article{$Attribute},
'Email for [...]',
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/SMIME/CertificateRemoveRelations.t
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if ( !-e $OpenSSLBin ) {
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');

if ( !$SMIMEObject ) {
print STDERR "NOTICE: No SMIME support!\n";
diag "NOTICE: No SMIME support!";

if ( !-e $OpenSSLBin ) {
$Self->False(
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/SMIME/ConvertCertFormat.t
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $ConfigObject->Set(
);

# check if openssl is located there
if ( !-e $ConfigObject->Get('SMIME::Bin') ) {
if ( !$ConfigObject->Get('SMIME::Bin') || !-e $ConfigObject->Get('SMIME::Bin') ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/openssl' ) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/test/SMIME/FetchFromCustomer.t
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $ConfigObject->Set(
);

# check if openssl is located there
if ( !-e $OpenSSLBin ) {
if ( !$OpenSSLBin || !-e $OpenSSLBin ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/openssl' ) {
Expand All @@ -90,7 +90,7 @@ if ( !-e $OpenSSLBin ) {
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');

if ( !$SMIMEObject ) {
print STDERR "NOTICE: No SMIME support!\n";
diag "NOTICE: No SMIME support!";

if ( !-e $OpenSSLBin ) {
$Self->False(
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/Selenium/Agent/AgentStatistics/Add.t
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ $Selenium->RunTest(
$Selenium->WaitFor( JavaScript => 'return typeof($) === "function" && !$(".Dialog.Modal").length;' );

# Check error message if there is set wrong invalid date for x-axis
if ( $StatsData->{XAxis} eq 'XAxisCreateTime' ) {
if ( $StatsData->{XAxis} && $StatsData->{XAxis} eq 'XAxisCreateTime' ) {
$Self->Is(
$Selenium->execute_script("return \$('.Preview p.Error').text().trim();"),
"CreateTime: The selected date is not valid.",
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/Selenium/Output/Preferences/Customer/PGP.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $Selenium->RunTest(
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');

# check if gpg is located there
if ( !-e $ConfigObject->Get('PGP::Bin') ) {
if ( !$ConfigObject->Get('PGP::Bin') || !-e $ConfigObject->Get('PGP::Bin') ) {

# maybe it's a mac with macport
if ( -e '/opt/local/bin/gpg' ) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/Ticket/Article/Backend/Chat.t
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ for my $Test (@ArticleCreateTests) {
else {
$Self->False(
$ArticleID,
"$Test->{Name} - Article not created - $ArticleID",
"$Test->{Name} - Article not created",
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ $ConfigObject->Set(
my $SMIMEObject = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');

if ( !$SMIMEObject ) {
print STDERR "NOTICE: No SMIME support!\n";
diag "NOTICE: No SMIME support!";

if ( !-e $OpenSSLBin ) {
$Self->False(
Expand Down

0 comments on commit acf3df3

Please sign in to comment.