Fix to use foreign_defined sub instead

This commit is contained in:
iliajie
2022-10-01 18:29:39 +03:00
parent 261e5eaf40
commit d0ed52adf7
4 changed files with 6 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@@ -58,7 +58,7 @@ foreach $o (@lang_order_list) {
}
# Call any config pre-load function
if (&foreign_func_exists($module, 'config_pre_load')) {
if (&foreign_defined($module, 'config_pre_load')) {
&foreign_call($module, "config_pre_load", \%info, \@info_order);
&foreign_call($module, "config_pre_load", \%einfo);
}
@@ -281,7 +281,7 @@ if ($section) {
# prevent changing behaviour of a module
if (&foreign_exists($module) &&
&foreign_require($module) &&
&foreign_func_exists($module, 'config_pre_load')) {
&foreign_defined($module, 'config_pre_load')) {
&foreign_call($module, "config_pre_load", \%info, \@info_order);
}

View File

@@ -26,7 +26,7 @@ $help || &helperror(&text('help_efile3',
# Modify help file based on module
if (&foreign_exists($module) &&
&foreign_require($module) &&
&foreign_func_exists($module, 'help_pre_load')) {
&foreign_defined($module, 'help_pre_load')) {
$help = &foreign_call($module, "help_pre_load", $help);
}

View File

@@ -3783,25 +3783,6 @@ my $mdir = &module_root_directory($_[0]);
return -r "$mdir/module.info";
}
=head2 foreign_func_exists(module, func)
Checks if module exists and if the
given module's function is defined
=cut
sub foreign_func_exists
{
my ($mod, $func) = @_;
if (&foreign_exists($mod)) {
$mod =~ s/-/_/g;
$func = "${mod}::${func}";
if (defined(&$func)) {
return 1;
}
}
return 0;
}
=head2 foreign_available(module)
Returns 1 if some module is installed, and accessible to the current user. The
@@ -4032,9 +4013,9 @@ simpler to use the syntax &defined(module::function) instead.
=cut
sub foreign_defined
{
my ($pkg) = @_;
my ($pkg, $sub) = @_;
$pkg =~ s/[^A-Za-z0-9]/_/g;
my $func = "${pkg}::$_[1]";
my $func = "${pkg}::${sub}";
return defined(&$func);
}