Question about custom module loading

English! place to talk about development, programming and coding
Post Reply
voiprodrigo
Znuny newbie
Posts: 62
Joined: 03 Dec 2014, 18:49
Znuny Version: OTRS 4
Location: Portugal
Contact:

Question about custom module loading

Post by voiprodrigo »

Hello,

Can anyone ex'plain to me how does custom module loading happens? I see that Kernel::System::Ticket includes a routine that loads custom Kernel::System::Ticket:: modules, but what about a module like Kernel::System::CustomModule, how is it loaded and able to override a function in another Kernel::System core module?

Thanks!
Linux (Ubuntu 14.04.1 LTS) | MySQL 5.5.40 | OTRS 4.0.7
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Question about custom module loading

Post by RStraub »

Hey there,

two things you should differentiate:

1) Loading ->
Happens when you create a (well formed) .xml file in ~otrs/Kernel/Config/Files. Everytime you run the RebuildConfig script, or access the SysConfig link in the admin section, these files are read and processed. If there are new (or changed) files with the proper syntax, the according modules are beeing loaded.
OTRS "knows" what kind of module is beeing loaded, based on the ConfigItem Name (the string before the ###).

2) Overriding -> (Shouldn't be needed, you can do most of the stuff with custom modules or modification of the config values)
You could of course change the original files, which I strongly reccommend against. Rather create a custom .xml file and in the header of the xml definition, set the init value to Changes, like so:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<otrs_config version="1.0" init="Changes">
[...]
</otrs_config>
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
voiprodrigo
Znuny newbie
Posts: 62
Joined: 03 Dec 2014, 18:49
Znuny Version: OTRS 4
Location: Portugal
Contact:

Re: Question about custom module loading

Post by voiprodrigo »

Thanks for the explanation! Meanwhile I also took a closer look at the code, to understand this better, like the code bits that actually load modules defined in the xml. I was also trying to understand why a custom module (loaded via xml) is failing to do method overriding (essentially, attempting a subroutine re-definition by re-declaring it within the custom module after (supposedly) the original one, for example declaring sub Kernel::System::SomeModule::somesub {...} in CustomModule.pm. But that I suspect is a pure Perl issue.

rgds
Linux (Ubuntu 14.04.1 LTS) | MySQL 5.5.40 | OTRS 4.0.7
Post Reply