View Issue Details

IDProjectCategoryView StatusLast Update
0035440mantisbtplug-inspublic2025-02-24 12:45
Reporterraspopov Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformMicrosoftOSWindows ServerOS Version2022
Product Version2.27.0 
Summary0035440: Plugins load when they don't need to and don't load when they do
Description

While debugging a strange issue in my MantisBT external authentication plugin, I discovered that MantisBT disables plugin loading for some tasks: installing, uninstalling, updating and upgrading plugins. By using:

define( 'PLUGINS_DISABLED', true );

After that, because the authentication plugin is disabled, the next call to auth_reauthenticate() that tries to re-authenticate will fail. :-(
Of course, this can be disabled with the $g_reauthentication = OFF; option, but this is a special case and we need a general solution.

What's the point of disabling plugins for this?

There is also the opposite example.
In MantisBT plugins are loaded even if they cannot be called in principle, e.g. in:

  • plugin_file.php (loads js/css for every page per plugin)
  • javascript_config.php (loads js for every page)
  • javascript_translations.php (loads js for every page)
  • css/status_config.php (loads css for every page)
    This has an impact on performance.

It seems that it is necessary to disable the forced loading of plugins in core.php and load them lazily, at the first function call, for example, when calling events.

Additional Information

By the way for what purpose in plugin_file.php is called?

$t_plugin = plugin_get( $t_basename );

The result of the function is not used, and there is no point in checking that the plugin is loaded...

TagsNo tags attached.

Activities

raspopov

raspopov

2025-02-24 12:45

reporter   ~0069907

Maybe try to change the auth_reauthentication_enabled() function in the authentication_api.php like this?

function auth_reauthentication_enabled() {
    if( defined( 'PLUGINS_DISABLED' ) ) {
        // Do not in case authentication plugins may be disabled
        return false;
    }
    $t_auth_flags = auth_flags();
    return $t_auth_flags->getReauthenticationEnabled();
}