RotherOSS / FAQ

The FAQ/knowledge base.
0 stars 3 forks source link

Package reinstall from command line throws DB errors #3

Closed wollmers closed 2 years ago

wollmers commented 3 years ago

OTOBO Version 10.0.5 FAQ Version 10.0.0 fetched from git ba8e45f

Severity: minor (workaround: install via web interface)

Impact: Caused unusable installation the first time. Now reproducing results in a working installation.

Remark: Update of uploaded package via web interface works (no errors in the logs)

Reproduce and log:

$ bin/otobo.Console.pl Dev::Package::Build --module-directory faq faq/FAQ.sopm .
Building package...
Done.

$ bin/otobo.Console.pl Admin::Package::Install FAQ-10.0.0.opm
[...]
Done.

$ bin/otobo.Console.pl Admin::Package::Reinstall FAQ-10.0.0.opm
Reinstalling package...
[...]

        # create the package name
        my $CodeModule = 'var::packagesetup::' . $Param{Structure}->{Name}->{Content};

        $Kernel::OM->Get($CodeModule)->CodeReinstall();

[Fri Nov  6 16:59:04 2020] otobo.Console.pl: DBD::mysql::db do failed: Duplicate entry 'external (customer)' for key 'faq_state_name' at /home/VirtualOTOBO/ov14/Kernel/System/DB.pm line 566.
ERROR: OTOBO-otobo.Console.pl-Admin::Package::Reinstall-14 Perl: 5.26.1 OS: linux Time: Fri Nov 6 15:59:04 2020

 Message: Duplicate entry 'external (customer)' for key 'faq_state_name', SQL: '
            INSERT INTO faq_state (name, type_id)
            VALUES ( ?, ? )'

 Traceback (4038): 
   Module: Kernel::Config::Files::AAAFred::__ANON__ Line: 125
   Module: Kernel::System::FAQ::State::StateAdd Line: 74
   Module: var::packagesetup::FAQ::_InsertFAQStates Line: 326
   Module: var::packagesetup::FAQ::CodeReinstall Line: 136
   Module: (eval) Line: 6
   Module: Kernel::System::Package::_Code Line: 3652
   Module: Kernel::System::Package::PackageReinstall Line: 751
   Module: Kernel::System::Console::Command::Admin::Package::Reinstall::Run Line: 87
   Module: (eval) Line: 468
   Module: Kernel::System::Console::BaseCommand::Execute Line: 462
   Module: Kernel::System::Console::InterfaceConsole::Run Line: 88
   Module: bin/otobo.Console.pl Line: 35

[Fri Nov  6 16:59:04 2020] otobo.Console.pl: DBD::mysql::db do failed: Duplicate entry 'internal (agent)' for key 'faq_state_name' at /home/VirtualOTOBO/ov14/Kernel/System/DB.pm line 566.
ERROR: OTOBO-otobo.Console.pl-Admin::Package::Reinstall-14 Perl: 5.26.1 OS: linux Time: Fri Nov 6 15:59:04 2020

 Message: Duplicate entry 'internal (agent)' for key 'faq_state_name', SQL: '
            INSERT INTO faq_state (name, type_id)
            VALUES ( ?, ? )'

[Traceback same as above]

[Fri Nov  6 16:59:04 2020] otobo.Console.pl: DBD::mysql::db do failed: Duplicate entry 'public (all)' for key 'faq_state_name' at /home/VirtualOTOBO/ov14/Kernel/System/DB.pm line 566.
ERROR: OTOBO-otobo.Console.pl-Admin::Package::Reinstall-14 Perl: 5.26.1 OS: linux Time: Fri Nov 6 15:59:04 2020

 Message: Duplicate entry 'public (all)' for key 'faq_state_name', SQL: '
            INSERT INTO faq_state (name, type_id)
            VALUES ( ?, ? )'

[Traceback same as above]

Done.
bschmalhofer commented 2 years ago

The installation code of the FAQ module chooses to ignore the failures from StateAdd()when that method is called in var/packagesetup/FAQ.pm . This is not the optional solution as there could be other errors besides that the states already exists.

        # add the state
        $FAQObject->StateAdd(
            Name   => $State{$Type},
            TypeID => $StateTypeRef->{StateID},
            UserID => 1,
        );

That the log messages are shown when called on the command line is fine in my opinion.

As there are no major reported problems with the FAQ module I would accept the current behavior.