Plugins question

Is it normal that one should have to add plugin locations to @INC for
scripts that don’t use them?
I’m using RTx::Calendar (added to @Plugins in RT_SiteConfig.pm) and also
http://wiki.bestpractical.com/view/rtReminderMails (with a few patches below)

To get the latter to work I have to do
use lib qw’/opt/rt3/lib /opt/rt3/local/plugins/RTx-Calendar/lib/’;
which seems rather gauche.

Patch 1: Report old reminders too
Patch 2: Reorder to show oldest (and presumably most important) first
Patch 3: English error
Patch 4: Access configuration variables in 3.8 style so that the script works

— /tmp/a 2008-09-05 16:50:40.000000000 -0400
+++ /tmp/b 2008-09-05 16:51:06.000000000 -0400
@@ -1,6 +1,8 @@

Calculate date boundaries.

my($dy,$dm,$dd) = Today();
-my $d_now = sprintf(’%04d-%02d-%02d 00:00:00’, $dy, $dm, $dd);
+#XXX Fetch overdue instead
+my $d_now = sprintf(’%04d-%02d-%02d 00:00:00’, 2008, 8, 14);
+#my $d_now = sprintf(’%04d-%02d-%02d 00:00:00’, $dy, $dm, $dd);
my $d_then = sprintf(’%04d-%02d-%02d 23:59:59’, Add_Delta_Days($dy,
$dm, $dd, $CONFIG_DUE_DAYS));

Fetch list of matching tickets.

@@ -9,8 +11,8 @@
'Type = “reminder” AND ‘.
’(Status = “new” OR Status = “open”) AND ‘.
‘Due >= "’.$d_now.’" AND '.

  •               'Due <= "'.$d_then.'"');
    

-$reminders->OrderBy(FIELD => ‘Due’, ORDER => ‘DESC’);

  •            'Due <= "'.$d_then.'"');
    

+$reminders->OrderBy(FIELD => ‘Due’, ORDER => ‘ASC’);

Format result and group by e-mail address.

my %rcpts = ();
@@ -19,7 +21,7 @@

 # Can this ever happen?
 if ( ! $reminder->RefersTo->First) {
  •    $out .= "ERROR: \$reminder->RefersTo->First ist
    

leer:\n".Dumper($reminder)."\n\n";

  •    $out .= "ERROR: \$reminder->RefersTo->First is
    

empty:\n".Dumper($reminder)."\n\n";
next;
}
my $ticket = $reminder->RefersTo->First->TargetObj;
@@ -53,7 +55,7 @@
"\n".
$rcpts{$rcpt};
# FIXME: Is there no proper RT library for this?

  • open(MAIL, “| $RT::SendmailPath $RT::SendmailBounceArguments
    $RT::SendmailArguments”) or die(“open sendmail: $!”);
  • open(MAIL, ‘|’. RT->Config->Get(‘SendmailPath’) .’ ‘.
    RT->Config->Get(‘SendmailBounceArguments’) .’ '.
    RT->Config->Get(‘SendmailArguments’)) or die(“open sendmail: $!”);
    print(MAIL $mail) or die(“print sendmail: $!”);
    close(MAIL) or die(“close sendmail: $!”);
    }

Cambridge Energy Alliance: Save money & the planet

Is it normal that one should have to add plugin locations to @INC for
scripts that don’t use them?
I’m using RTx::Calendar (added to @Plugins in RT_SiteConfig.pm) and
also
http://wiki.bestpractical.com/view/rtReminderMails (with a few
patches below)

To get the latter to work I have to do
use lib qw’/opt/rt3/lib /opt/rt3/local/plugins/RTx-Calendar/lib/’;

RT.pm’s Plugins code certainly should be adding the right thing to the
lib path. Does it not?

RT.pm’s Plugins code certainly should be adding the right thing to the lib
path. Does it not?

Umm no hence

To get the latter to work I have to do

use lib qw’/opt/rt3/lib /opt/rt3/local/plugins/RTx-Calendar/lib/’;

[Sun Sep 7 19:15:25 2008] [crit]: Can’t locate RTx/Calendar.pm in @INC
(@INC contains: /opt/rt3/lib /usr/lib/perl5/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at /opt/rt3/lib/RT.pm line 624.
(/opt/rt3/lib/RT.pm:377)
Can’t locate RTx/Calendar.pm in @INC (@INC contains: /opt/rt3/lib
/usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4
/usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2
/usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4
/usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2
/usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl .) at /opt/rt3/lib/RT.pm line 624.

argh grumble Reply-to grumble
Cambridge Energy Alliance: Save money & the planet

[Please keep the list CCed]

RT.pm’s Plugins code certainly should be adding the right thing to
the lib path. Does it not?

Umm no hence

Are you perhaps trying to write your own scripts that use RT’s
libraries and not calling RT::Init?

is sub RT::InitPluginPaths getting called? Is it finding the plugin
directory? Is it deciding to skip the plugin’s lib dir for some reason?

You’ll likely need to actually add a bit of logging or debugging
output to the core to see what’s going wrong so you can help us fix it.

Best,
Jesse

Are you perhaps trying to write your own scripts that use RT’s libraries
and not calling RT::Init?

As stated, I am trying to use a script from the wiki, but I happen to have
plugins installed.
Said script makes no use of plugins, and does in fact call RT::Init.

is sub RT::InitPluginPaths getting called? Is it finding the plugin
directory? Is it deciding to skip the plugin’s lib dir for some reason?

Actually the test:
if ( Cwd::realpath($_) eq $RT::LocalLibPath) {
fails, and only that branch allows @tmp_libs #$self->PluginDirs(‘lib’)
into @INC

Apparently the oft-cargo-culted script initialization is not very robust,
and it should have
use lib qw’/opt/rt3/lib /opt/rt3/local/lib’;

You’ll likely need to actually add a bit of logging or debugging output to

the core to see what’s going wrong so you can help us fix it.

Done, but I wonder if a larger design issue is at hand, namely that there
seems to be no allowance for a minimal setup e.g; no plugins; to support the
proper initialization of scripts…

Cambridge Energy Alliance: Save money & the planet

I am trying to add the same plugin, the Calendar, but I can’t have it
work.

I have added the component in the Prefs/MyRT.html page and on the first
page I now have this error :

could not find component for path ‘MyCalendar’

I tried to modify the Header page to see if the modification was made
when restarting apache and it worked, but I don’t know what to change to
include the plugins folder for apache.

The path to my plugins folder (on local) is :

/usr/local/share/request-tracker3.8/

The path for the share one is :

/usr/share/request-tracker3.8

If anyone can help me it would be wonderful I am trying to fix this
problem for quite a long time…

Thanks

Alexandre

Hello!

I’m not absolut sure if I you have the same problem but there seems to
be a bug in the install system

I have in my site config, the follwing line:
Set(@Plugins,(qw(RTx::EmailCompletion RTx::BecomeUser)));

If I look in RT.pm I see the following function:
sub PluginDirs {

$plugindir =~ s/::/-/g;

#the plugin dir is now RTx-EmailCompletion

next unless -d $path;

this will be always executed because my local plugin dir look like

#[root@rt-testsys-1 plugins]# ls
#/opt/rt3/local/plugins/BecomeUser
#/opt/rt3/local/plugins/EmailCompletion

    push @res, $path;

#we will never arrive here

My workaround was to create symlinks with the “RTx-” prefix,
and after cleaning the mason cache everything works.

So there is obvisioly a bug, in the plugin installer or
in RT.

regards!

sven