[Rt-commit] rt branch 5.0/replace-universal-require created. rt-5.0.3-224-g8b30892d6f
BPS Git Server
git at git.bestpractical.com
Tue Jan 17 13:21:32 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/replace-universal-require has been created
at 8b30892d6f051d714987f839e090a01c15d139dc (commit)
- Log -----------------------------------------------------------------
commit 8b30892d6f051d714987f839e090a01c15d139dc
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date: Tue Jan 17 06:09:08 2023 -0300
[ẂIP] Replace UNIVERSAL::require with Module::Runtime::require_module
Tests may pass (or not) now, but still work to do.
Created a sub RequireModule in RT package so it can be a proxy for
any future update if needed.
Updated all the places where UNIVERSAL::require was used.
Still need to check some exceptions which used $UNIVERSAL::require::ERROR
or $@ locally, as well as update docs.
diff --git a/bin/rt-crontool.in b/bin/rt-crontool.in
index 0102b9b5a2..9a8151cef8 100644
--- a/bin/rt-crontool.in
+++ b/bin/rt-crontool.in
@@ -337,7 +337,7 @@ sub get_template {
sub load_module {
my $modname = shift;
- unless ($modname->require) {
+ unless (RT::RequireModule($modname)) {
my $error = $@;
die loc( "Failed to load module [_1]. ([_2])", $modname, $error );
}
diff --git a/etc/cpanfile b/etc/cpanfile
index 842371301e..867509a740 100644
--- a/etc/cpanfile
+++ b/etc/cpanfile
@@ -87,7 +87,6 @@ requires 'Text::Wrapper';
requires 'Time::HiRes';
requires 'Time::ParseDate';
requires 'Tree::Simple', '>= 1.04';
-requires 'UNIVERSAL::require';
requires 'URI', '>= 1.59';
requires 'URI::QueryParam';
requires 'XML::RSS', '>= 1.05';
diff --git a/lib/RT.pm b/lib/RT.pm
index 4f3a3ebff2..98f28af585 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -57,7 +57,8 @@ use Encode ();
use File::Spec ();
use Cwd ();
use Scalar::Util qw(blessed);
-use UNIVERSAL::require;
+use Module::Runtime qw/require_module/;
+
use vars qw($Config $System $SystemUser $Nobody $Handle $Logger $CurrentInterface $_Privileged $_Unprivileged $_INSTALL_MODE);
@@ -522,7 +523,7 @@ sub InitClasses {
}
foreach my $class ( grep $_, RT->Config->Get('CustomFieldValuesSources') ) {
- $class->require or $RT::Logger->error(
+ RT::RequireModule($class) or $RT::Logger->error(
"Class '$class' is listed in CustomFieldValuesSources option"
." in the config, but we failed to load it:\n$@\n"
);
@@ -846,13 +847,32 @@ sub InitPlugins {
if ( $CORED_PLUGINS{$plugin} ) {
RT->Logger->warning( "$plugin has been cored since RT $CORED_PLUGINS{$plugin}, please check the upgrade document for more details" );
}
- $plugin->require;
+ RT::RequireModule($plugin);
die $UNIVERSAL::require::ERROR if ($UNIVERSAL::require::ERROR);
push @plugins, RT::Plugin->new(name =>$plugin);
}
return @plugins;
}
+=head2 RequireModule
+
+Provides a safe mechanism for loading a module at runtime, when you have
+the name of the module in a variable.
+
+=cut
+
+sub RequireModule {
+ my $module = shift;
+ # try to require the module
+ $RT::RequireModule::ERROR='';
+ eval { require_module($module) };
+ if ($@) {
+ my $error = $@;
+ $RT::RequireModule::ERROR="Couldn't load module $module: $error";
+ return (0);
+ }
+ return (1);
+}
sub InstallMode {
my $self = shift;
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 8b6dc5ea0f..4228e5f27e 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -659,7 +659,7 @@ sub EncodedHeaders {
# Require Encode::HanExtra to handle more encodings it supports.
# The regex is based on the names documented in Encode::HanExtra.
if ( $encoding =~ /^(?:big5(?:-1984|-2003|ext|plus)|cccii|cns11643-[1-7f]|euc-tw|gb18030|unisys(?:-sosi(?:1|2))?)$/ ) {
- unless ( Encode::HanExtra->require ) {
+ unless ( RT::RequireModule("Encode::HanExtra") ) {
RT->Logger->error("Need Encode::HanExtra to handle $encoding");
}
}
diff --git a/lib/RT/Authen/ExternalAuth/DBI.pm b/lib/RT/Authen/ExternalAuth/DBI.pm
index 13c8303b9d..4f22c7ac82 100644
--- a/lib/RT/Authen/ExternalAuth/DBI.pm
+++ b/lib/RT/Authen/ExternalAuth/DBI.pm
@@ -300,7 +300,7 @@ sub GetAuth {
# Use config info to auto-load the perl package needed for password encryption
# Jump to next external authentication service on failure
- $db_p_enc_pkg->require or do {
+ RT::RequireModule($db_p_enc_pkg) or do {
$RT::Logger->error("AUTH FAILED, Couldn't Load Password Encryption Package. Error: $@");
return 0;
};
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index ea99df798d..e04d1b6046 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -827,7 +827,7 @@ our %META;
my $self = shift;
my $value = shift;
return if $value;
- return if GraphViz2->require;
+ return if RT::RequireModule("GraphViz2");
$RT::Logger->debug("You've enabled GraphViz, but we couldn't load the module: $@");
$self->Set( DisableGraphViz => 1 );
},
@@ -839,7 +839,7 @@ our %META;
my $self = shift;
my $value = shift;
return if $value;
- return if GD->require;
+ return if RT::RequireModule("GD");
$RT::Logger->debug("You've enabled GD, but we couldn't load the module: $@");
$self->Set( DisableGD => 1 );
},
@@ -1313,7 +1313,7 @@ our %META;
my $spec = $ranges->{$class}{$name};
if (!ref($spec) || ref($spec) eq 'HASH') {
# this will produce error messages if parsing fails
- $class->require;
+ RT::RequireModule($class);
$class->_ParseCustomDateRangeSpec($name, $spec);
}
else {
diff --git a/lib/RT/Crypt.pm b/lib/RT/Crypt.pm
index 6b8230348e..9c7717446c 100644
--- a/lib/RT/Crypt.pm
+++ b/lib/RT/Crypt.pm
@@ -296,7 +296,7 @@ sub LoadImplementation {
my $class = 'RT::Crypt::'. $proto;
return $cache{ $class } if exists $cache{ $class };
- if ($class->require) {
+ if (RT::RequireModule($class)) {
return $cache{ $class } = $class;
} else {
RT->Logger->warn( "Could not load $class: $@" );
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index ac7b6d89e4..946d801ea9 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -643,7 +643,7 @@ sub Values {
my $class = $self->ValuesClass;
if ( $class ne 'RT::CustomFieldValues') {
- $class->require or die "Can't load $class: $@";
+ RT::RequireModule($class) or die "Can't load $class: $@";
}
my $cf_values = $class->new( $self->CurrentUser );
$cf_values->SetCustomFieldObject( $self );
@@ -1791,7 +1791,7 @@ sub _CanonicalizeValueWithCanonicalizer {
my $class = $self->__Value('CanonicalizeClass') or return 1;
- $class->require or die "Can't load $class: $@";
+ RT::RequireModule($class) or die "Can't load $class: $@";
my $canonicalizer = $class->new($self->CurrentUser);
$args->{'Content'} = $canonicalizer->CanonicalizeValue(
diff --git a/lib/RT/ExternalStorage/AmazonS3.pm b/lib/RT/ExternalStorage/AmazonS3.pm
index a72aa1d0dd..7ddd66a732 100644
--- a/lib/RT/ExternalStorage/AmazonS3.pm
+++ b/lib/RT/ExternalStorage/AmazonS3.pm
@@ -85,7 +85,7 @@ sub BucketObj {
sub Init {
my $self = shift;
- if (not Amazon::S3->require) {
+ if (not RT::RequireModule("Amazon::S3")) {
RT->Logger->error("Required module Amazon::S3 is not installed");
return;
}
diff --git a/lib/RT/ExternalStorage/Backend.pm b/lib/RT/ExternalStorage/Backend.pm
index 6ec8cf38b5..303caef28b 100644
--- a/lib/RT/ExternalStorage/Backend.pm
+++ b/lib/RT/ExternalStorage/Backend.pm
@@ -66,11 +66,11 @@ sub new {
if (not $class) {
RT->Logger->error("No storage engine type provided");
return undef;
- } elsif ($class->require) {
+ } elsif (RT::RequireModule($class)) {
# no action needed; $class was loaded
} else {
my $long = "RT::ExternalStorage::$class";
- if ($long->require) {
+ if (RT::RequireModule($long)) {
$class = $long;
} else {
RT->Logger->error("Can't load external storage engine $class: $@");
diff --git a/lib/RT/ExternalStorage/Dropbox.pm b/lib/RT/ExternalStorage/Dropbox.pm
index f69bc7741a..4b5a09d475 100644
--- a/lib/RT/ExternalStorage/Dropbox.pm
+++ b/lib/RT/ExternalStorage/Dropbox.pm
@@ -70,7 +70,7 @@ sub AccessToken {
sub Init {
my $self = shift;
- if (not File::Dropbox->require) {
+ if (not RT::RequireModule("File::Dropbox")) {
RT->Logger->error("Required module File::Dropbox is not installed");
return;
} elsif (not $self->AccessToken) {
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 5b63911441..9844c31c34 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -86,8 +86,7 @@ L<DBIx::SearchBuilder::Handle>, using the C<DatabaseType> configuration.
sub FinalizeDatabaseType {
my $db_type = RT->Config->Get('DatabaseType');
my $package = "DBIx::SearchBuilder::Handle::$db_type";
-
- $package->require or
+ RT::RequireModule($package) or
die "Unable to load DBIx::SearchBuilder database handle for '$db_type'.\n".
"Perhaps you've picked an invalid database type or spelled it incorrectly.\n".
$@;
@@ -892,7 +891,7 @@ sub InsertData {
foreach my $handler_candidate (@$handlers) {
next if $handler_candidate eq 'perl';
- $handler_candidate->require
+ RT::RequireModule($handler_candidate)
or die "Config option InitialdataFormatHandlers lists '$handler_candidate', but it failed to load:\n$@\n";
if ($handler_candidate->CanLoad($datafile_content)) {
diff --git a/lib/RT/Installer.pm b/lib/RT/Installer.pm
index 5ece0af164..cf0e7f5fce 100644
--- a/lib/RT/Installer.pm
+++ b/lib/RT/Installer.pm
@@ -61,7 +61,7 @@ my %Meta = (
Values => [
grep {
my $m = 'DBD::' . $_;
- $m->require ? 1 : 0
+ RT::RequireModule($m) ? 1 : 0
} qw/mysql Pg SQLite Oracle/
],
ValuesLabel => {
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 1218b6280f..5862e2d79e 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -290,7 +290,7 @@ sub Plugins {
my $Class = $plugin;
$Class = "RT::Interface::Email::" . $Class
unless $Class =~ /^RT::/;
- $Class->require or
+ RT::RequireModule($Class) or
do { $RT::Logger->error("Couldn't load $Class: $@"); next };
unless ( $Class->DOES( "RT::Interface::Email::Role" ) ) {
@@ -1527,7 +1527,7 @@ sub _HTMLFormatter {
} else {
my $path = $prog =~ s{(.*/)}{} ? $1 : undef;
my $package = "HTML::FormatText::" . ucfirst($prog);
- unless ($package->require) {
+ unless (RT::RequireModule($package)) {
RT->Logger->warn("$prog is not a valid formatter provided by HTML::FormatExternal")
if $wanted;
next;
diff --git a/lib/RT/Interface/Web/Handler.pm b/lib/RT/Interface/Web/Handler.pm
index f64a1e0c1d..e33ff9b870 100644
--- a/lib/RT/Interface/Web/Handler.pm
+++ b/lib/RT/Interface/Web/Handler.pm
@@ -110,7 +110,7 @@ sub InitSessionDir {
sub NewHandler {
my $class = shift;
- $class->require or die $!;
+ RT::RequireModule($class) or die $!;
my $handler = $class->new(
DefaultHandlerArgs(),
RT->Config->Get('MasonParameters'),
diff --git a/lib/RT/Interface/Web/Session.pm b/lib/RT/Interface/Web/Session.pm
index f86a6a5e26..64b7811ff8 100644
--- a/lib/RT/Interface/Web/Session.pm
+++ b/lib/RT/Interface/Web/Session.pm
@@ -84,7 +84,7 @@ sub Class {
my $class = RT->Config->Get('WebSessionClass')
|| $self->Backends->{RT->Config->Get('DatabaseType')}
|| 'Apache::Session::File';
- $class->require or die "Can't load $class: $@";
+ RT::RequireModule($class) or die "Can't load $class: $@";
return $class;
}
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 51ac72fc66..cf8b2485cd 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -160,7 +160,7 @@ sub Load {
}
my $class = "RT::Lifecycle::".ucfirst($args{Type});
- bless $self, $class if $class->require;
+ bless $self, $class if RT::RequireModule($class);
return $self;
}
@@ -764,7 +764,7 @@ sub FillCache {
}
my $class = "RT::Lifecycle::".ucfirst($type);
- $class->RegisterRights if $class->require
+ $class->RegisterRights if RT::RequireModule($class)
and $class->can("RegisterRights");
}
diff --git a/lib/RT/Migrate/Serializer.pm b/lib/RT/Migrate/Serializer.pm
index bce8530f22..661b9f8b61 100644
--- a/lib/RT/Migrate/Serializer.pm
+++ b/lib/RT/Migrate/Serializer.pm
@@ -177,9 +177,9 @@ sub PushAll {
$self->PushCollections(qw(Catalogs Assets));
# Custom Fields
- if (RT::ObjectCustomFields->require) {
+ if (RT::RequireModule("RT::ObjectCustomFields")) {
$self->PushCollections(map { ($_, "Object$_") } qw(CustomFields CustomFieldValues));
- } elsif (RT::TicketCustomFieldValues->require) {
+ } elsif (RT::RequireModule("RT::TicketCustomFieldValues")) {
$self->PushCollections(qw(CustomFields CustomFieldValues TicketCustomFieldValues));
}
@@ -199,7 +199,7 @@ sub PushCollections {
for my $type (@_) {
my $class = "RT::\u$type";
- $class->require or next;
+ RT::RequireModule($class) or next;
my $collection = $class->new( RT->SystemUser );
$collection->FindAllRows if $self->{FollowDisabled};
$collection->CleanSlate; # some collections (like groups and users) join in _Init
@@ -312,7 +312,7 @@ sub PushBasics {
$self->PushObj( $groups );
}
- if (RT::Articles->require) {
+ if (RT::RequireModule("RT::Articles")) {
$self->PushCollections(qw(Topics Classes));
}
diff --git a/lib/RT/REST2/Resource/Collection.pm b/lib/RT/REST2/Resource/Collection.pm
index e3ea2cedee..e53062d1b1 100644
--- a/lib/RT/REST2/Resource/Collection.pm
+++ b/lib/RT/REST2/Resource/Collection.pm
@@ -159,7 +159,7 @@ sub serialize {
if ( $field eq '_hyperlinks' ) {
my $class = ref $item;
$class =~ s!^RT::!RT::REST2::Resource::!;
- if ( $class->require ) {
+ if ( RT::RequireModule($class) ) {
my $object = $class->new(
record_class => ref $item,
record_id => $item->id,
diff --git a/lib/RT/REST2/Resource/Record.pm b/lib/RT/REST2/Resource/Record.pm
index 16bc430712..2174daaed1 100644
--- a/lib/RT/REST2/Resource/Record.pm
+++ b/lib/RT/REST2/Resource/Record.pm
@@ -80,7 +80,7 @@ sub _build_record {
my $class = $self->record_class;
my $id = $self->record_id;
- $class->require;
+ RT::RequireModule($class);
my $record = $class->new( $self->current_user );
$record->Load($id) if $id;
diff --git a/lib/RT/Ruleset.pm b/lib/RT/Ruleset.pm
index 5fbacd5f3e..a546a28ac2 100644
--- a/lib/RT/Ruleset.pm
+++ b/lib/RT/Ruleset.pm
@@ -76,7 +76,7 @@ sub CommitRules {
sub Add {
my ($class, %args) = @_;
for (@{$args{Rules}}) {
- $_->require or die $UNIVERSAL::require::ERROR;
+ RT::RequireModule($_) or die $UNIVERSAL::require::ERROR;
}
push @RULE_SETS, $class->new(\%args);
}
diff --git a/lib/RT/ScripAction.pm b/lib/RT/ScripAction.pm
index 37b0ed7250..528fc79727 100644
--- a/lib/RT/ScripAction.pm
+++ b/lib/RT/ScripAction.pm
@@ -180,7 +180,7 @@ sub LoadAction {
my $module = $self->ExecModule;
my $type = 'RT::Action::' . $module;
- $type->require or die "Require of $type action module failed.\n$@\n";
+ RT::RequireModule($type) or die "Require of $type action module failed.\n$@\n";
return $self->{'Action'} = $type->new(
%args,
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index a186770f08..70d395e4b1 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -176,7 +176,7 @@ sub LoadCondition {
my $module = $self->ExecModule;
my $type = 'RT::Condition::' . $module;
- $type->require or die "Require of $type condition module failed.\n$@\n";
+ RT::RequireModule($type) or die "Require of $type condition module failed.\n$@\n";
return $self->{'Condition'} = $type->new(
ScripConditionObj => $self,
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 9a103ee3a3..854030355b 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -366,7 +366,7 @@ sub CastObjectsToRecords
RT::Shredder::Exception->throw( "Unsupported class $class" )
unless $class =~ /^\w+(::\w+)*$/;
$class = 'RT::'. $class unless $class =~ /^RTx?::/i;
- $class->require or die "Failed to load $class: $@";
+ RT::RequireModule($class) or die "Failed to load $class: $@";
my $obj = $class->new( RT->SystemUser );
die "Couldn't construct new '$class' object" unless $obj;
$obj->Load( $id );
diff --git a/lib/RT/Shredder/Plugin.pm b/lib/RT/Shredder/Plugin.pm
index 002ac03824..26a66664b3 100644
--- a/lib/RT/Shredder/Plugin.pm
+++ b/lib/RT/Shredder/Plugin.pm
@@ -138,7 +138,7 @@ sub List
delete $res{'Base'};
foreach my $name( keys %res ) {
my $class = join '::', qw(RT Shredder Plugin), $name;
- unless( $class->require ) {
+ unless( RT::RequireModule($class) ) {
delete $res{ $name };
next;
}
@@ -173,7 +173,7 @@ sub LoadByName
$name =~ /^\w+(::\w+)*$/ or return (0, "Invalid plugin name");
my $plugin = "RT::Shredder::Plugin::$name";
- $plugin->require or return( 0, "Failed to load $plugin" );
+ RT::RequireModule($plugin) or return( 0, "Failed to load $plugin" );
return wantarray ? ( 0, "Plugin '$plugin' has no method new") : 0 unless $plugin->can('new');
my $obj = eval { $plugin->new( @_ ) };
diff --git a/lib/RT/Test/Crypt.pm b/lib/RT/Test/Crypt.pm
index 7ef0a7ee68..26e34eb82e 100644
--- a/lib/RT/Test/Crypt.pm
+++ b/lib/RT/Test/Crypt.pm
@@ -74,7 +74,7 @@ sub import {
RT::Test::plan( skip_all => 'ENV SKIP_GPG_TESTS is set to true.' )
if $ENV{'SKIP_GPG_TESTS'};
RT::Test::plan( skip_all => 'GnuPG required.' )
- unless GnuPG::Interface->require;
+ unless RT::RequireModule("GnuPG::Interface");
RT::Test::plan( skip_all => 'gpg executable is required.' )
unless RT::Test->find_executable('gpg');
}
@@ -469,7 +469,7 @@ sub create_and_test_outgoing_emails {
}
sub gnupg_version {
- GnuPG::Interface->require or return;
+ RT::RequireModule("GnuPG::Interface") or return;
require version;
state $gnupg_version = version->parse(GnuPG::Interface->new->version);
}
diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
index f14cc682d8..70b6c3b9cc 100644
--- a/lib/RT/Test/GnuPG.pm
+++ b/lib/RT/Test/GnuPG.pm
@@ -75,7 +75,7 @@ sub import {
RT::Test::plan( skip_all => 'ENV SKIP_GPG_TESTS is set to true.' )
if $ENV{'SKIP_GPG_TESTS'};
RT::Test::plan( skip_all => 'GnuPG required.' )
- unless GnuPG::Interface->require;
+ unless RT::RequireModule("GnuPG::Interface");
RT::Test::plan( skip_all => 'gpg executable is required.' )
unless RT::Test->find_executable('gpg');
@@ -385,14 +385,14 @@ sub create_and_test_outgoing_emails {
}
sub gnupg_version {
- GnuPG::Interface->require or return;
+ RT::RequireModule("GnuPG::Interface") or return;
require version;
state $gnupg_version = version->parse(GnuPG::Interface->new->version);
}
sub new_homedir {
my $source = shift;
- return if $ENV{'SKIP_GPG_TESTS'} || !RT::Test->find_executable('gpg') || !GnuPG::Interface->require;
+ return if $ENV{'SKIP_GPG_TESTS'} || !RT::Test->find_executable('gpg') || RT::RequireModule("!GnuPG::Interface");
my $dir = tempdir();
if ($source) {
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index f7d28b09eb..f825836a01 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -209,7 +209,7 @@ sub Create {
# Add corresponding CustomFieldValue records for custom fields,
# the same as in RT::Authen::ExternalAuth::UpdateUserInfo.
# RT::Authen::ExternalAuth needs Net::LDAP, which might be unavailable
- if ( RT::Authen::ExternalAuth->require ) {
+ if ( RT::RequireModule("RT::Authen::ExternalAuth") ) {
RT::Authen::ExternalAuth::AddCustomFieldValue(%args);
}
diff --git a/sbin/rt-dump-initialdata.in b/sbin/rt-dump-initialdata.in
index 8e5064ed9b..3e57c23799 100644
--- a/sbin/rt-dump-initialdata.in
+++ b/sbin/rt-dump-initialdata.in
@@ -205,7 +205,7 @@ sub estimate {
$collection = $class . ( UNIVERSAL::can( $class . 'es', 'new' ) ? 'es' : 's' );
}
- if ($collection->require) {
+ if (RT::RequireModule($collection)) {
my $objs = $collection->new( RT->SystemUser );
$objs->FindAllRows;
$objs->UnLimit;
diff --git a/sbin/rt-dump-metadata.in b/sbin/rt-dump-metadata.in
index 8183f3c26b..969bb7fbb7 100644
--- a/sbin/rt-dump-metadata.in
+++ b/sbin/rt-dump-metadata.in
@@ -250,7 +250,7 @@ OBJECT:
}
}
- if ( RT::Attributes->require ) {
+ if ( RT::RequireModule("RT::Attributes") ) {
my $attributes = $obj->Attributes;
while ( my $attribute = $attributes->Next ) {
my $content = $attribute->Content;
diff --git a/sbin/rt-serializer.in b/sbin/rt-serializer.in
index c6fe187898..6dd0bacfff 100644
--- a/sbin/rt-serializer.in
+++ b/sbin/rt-serializer.in
@@ -249,7 +249,7 @@ sub estimate {
for my $class (@types) {
print "Estimating $class count...";
my $collection = $class . "s";
- if ($collection->require) {
+ if (RT::RequireModule($collection)) {
my $objs = $collection->new( RT->SystemUser );
$objs->FindAllRows;
$objs->UnLimit;
diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index daef955a53..098f69c005 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -323,9 +323,9 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
if ( $good ) {
# Improve message from class names to their friendly descriptions
$original = $original->Description
- if $original && $original->require;
+ if $original && RT::RequireModule($original);
$CanonicalizeClass = $CanonicalizeClass->Description
- if $CanonicalizeClass && $CanonicalizeClass->require;
+ if $CanonicalizeClass && RT::RequireModule($CanonicalizeClass);
if (!$original) {
$msg = loc("[_1] '[_2]' added",
diff --git a/share/html/Admin/Elements/EditCustomFieldValuesCanonicalizer b/share/html/Admin/Elements/EditCustomFieldValuesCanonicalizer
index 9753208502..3eab184f1c 100644
--- a/share/html/Admin/Elements/EditCustomFieldValuesCanonicalizer
+++ b/share/html/Admin/Elements/EditCustomFieldValuesCanonicalizer
@@ -61,7 +61,7 @@ my @canonicalizers;
foreach my $class( RT->Config->Get('CustomFieldValuesCanonicalizers') ) {
next unless $class;
- unless ($class->require) {
+ unless (RT::RequireModule($class)) {
$RT::Logger->crit("Couldn't load class '$class': $@");
next;
}
diff --git a/share/html/Admin/Elements/EditCustomFieldValuesSource b/share/html/Admin/Elements/EditCustomFieldValuesSource
index 04bda45e98..14f6485dfb 100644
--- a/share/html/Admin/Elements/EditCustomFieldValuesSource
+++ b/share/html/Admin/Elements/EditCustomFieldValuesSource
@@ -60,7 +60,7 @@ my @sources;
foreach my $class( 'RT::CustomFieldValues', RT->Config->Get('CustomFieldValuesSources') ) {
next unless $class;
- unless ($class->require) {
+ unless (RT::RequireModule($class)) {
$RT::Logger->crit("Couldn't load class '$class': $@");
next;
}
diff --git a/share/html/Admin/Tools/Theme.html b/share/html/Admin/Tools/Theme.html
index d1f3a77c87..2e944da452 100644
--- a/share/html/Admin/Tools/Theme.html
+++ b/share/html/Admin/Tools/Theme.html
@@ -309,7 +309,7 @@ my $imgdata;
my $colors;
my $valid_image_types;
-if (not RT->Config->Get('DisableGD') and Convert::Color->require) {
+if (not RT->Config->Get('DisableGD') and RT::RequireModule("Convert::Color")) {
require GD;
# Always find out what GD can read...
diff --git a/share/html/Dashboards/Queries.html b/share/html/Dashboards/Queries.html
index cdda5fb22f..202f962c1f 100644
--- a/share/html/Dashboards/Queries.html
+++ b/share/html/Dashboards/Queries.html
@@ -67,7 +67,7 @@ if ($m->request_path ne '/Admin/Global/SelfServiceHomePage.html') {
}
my $class = $self_service_dashboard ? 'RT::Dashboard::SelfService' : 'RT::Dashboard';
-$class->require;
+RT::RequireModule($class);
my $Dashboard = $class->new($session{'CurrentUser'});
my ($ok, $msg) = $Dashboard->LoadById($id);
unless ($ok) {
diff --git a/share/html/Dashboards/Render.html b/share/html/Dashboards/Render.html
index 187cfd0b80..52814f3c98 100644
--- a/share/html/Dashboards/Render.html
+++ b/share/html/Dashboards/Render.html
@@ -127,7 +127,7 @@ $m->callback(ARGSRef => \%ARGS,
skip_create => \$skip_create);
my $class = $self_service_dashboard ? 'RT::Dashboard::SelfService' : 'RT::Dashboard';
-$class->require;
+RT::RequireModule($class);
my $Dashboard = $class->new($session{'CurrentUser'});
my ($ok, $msg) = $Dashboard->LoadById($id);
unless ($ok) {
diff --git a/share/html/Install/Initialize.html b/share/html/Install/Initialize.html
index 3407830906..f85a434153 100644
--- a/share/html/Install/Initialize.html
+++ b/share/html/Install/Initialize.html
@@ -80,7 +80,7 @@ if ( $Run ) {
# RT::Handle's ISA is dynamical, so we need to unshift the right one.
my $class = 'DBIx::SearchBuilder::Handle::' . RT->Config->Get('DatabaseType');
- $class->require or die $UNIVERSAL::require::ERROR;
+ RT::RequireModule($class) or die $UNIVERSAL::require::ERROR;
unshift @RT::Handle::ISA, $class;
my $sysdbh = DBI->connect(
diff --git a/t/mail/dashboard-chart-with-utf8.t b/t/mail/dashboard-chart-with-utf8.t
index 960d3de818..04098f5bad 100644
--- a/t/mail/dashboard-chart-with-utf8.t
+++ b/t/mail/dashboard-chart-with-utf8.t
@@ -4,7 +4,7 @@ use warnings;
use RT::Test tests => undef;
plan skip_all => 'GD required'
- unless GD->require;
+ unless RT::RequireModule("GD");
my $root = RT::Test->load_or_create_user( Name => 'root' );
diff --git a/t/mail/han-encodings.t b/t/mail/han-encodings.t
index ba1acc0cd4..3a53d062f0 100644
--- a/t/mail/han-encodings.t
+++ b/t/mail/han-encodings.t
@@ -3,7 +3,7 @@ use warnings;
use RT::Test tests => undef, actual_server => 1;
-# we can't simply call Encode::HanExtra->require here because we are testing
+# we can't simply call RT::RequireModule("Encode::HanExtra") here because we are testing
# if Encode::HanExtra could be automatically loaded.
plan skip_all => 'Encode::HanExtra required' if system $^X, '-MEncode::HanExtra', '-e1';
diff --git a/t/security/CVE-2011-5092-graph-links.t b/t/security/CVE-2011-5092-graph-links.t
index 085e148b5e..0712a90f5d 100644
--- a/t/security/CVE-2011-5092-graph-links.t
+++ b/t/security/CVE-2011-5092-graph-links.t
@@ -4,7 +4,7 @@ use warnings;
use RT::Test tests => undef;
plan skip_all => 'GraphViz required.'
- unless GraphViz2->require;
+ unless RT::RequireModule("GraphViz2");
my ($base, $m) = RT::Test->started_ok;
$m->login;
diff --git a/t/web/charting.t b/t/web/charting.t
index bb7ecb87b2..739cb432fe 100644
--- a/t/web/charting.t
+++ b/t/web/charting.t
@@ -4,7 +4,7 @@ use warnings;
use RT::Test tests => undef, config => 'Set($EnableJSChart, 0);';
plan skip_all => 'GD required'
- unless GD->require;
+ unless RT::RequireModule("GD");
for my $n (1..7) {
my $ticket = RT::Ticket->new( RT->SystemUser );
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list