Skip to content

Commit 194cf35

Browse files
committed
Plugin: Load the plugin.php file in the right scope to get $plugin_info
1 parent 2954fc9 commit 194cf35

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

public/main/inc/lib/plugin.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function get_info()
110110
$result['is_course_plugin'] = $this->isCoursePlugin;
111111
$result['is_admin_plugin'] = $this->isAdminPlugin;
112112
$result['is_mail_plugin'] = $this->isMailPlugin;
113-
$result['entity'] = $pluginRepo->findOneByTitle($this->get_title());
113+
$result['entity'] = $pluginRepo->findOneByTitle($this->get_name());
114114

115115
if ($form = $this->getSettingsForm()) {
116116
$result['settings_form'] = $form;

public/main/inc/lib/plugin.lib.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,22 +453,27 @@ public function getPluginInfo($pluginName, $forced = false)
453453
$plugin_info = [];
454454
$pluginPath = api_get_path(SYS_PLUGIN_PATH);
455455

456-
$pluginDir = null;
457456
$posibleName = [
458457
$pluginName,
459458
strtolower($pluginName),
460459
ucfirst(strtolower($pluginName)),
461460
];
461+
462+
$plugin_file = null;
463+
462464
foreach ($posibleName as $dir) {
463465
$path = $pluginPath."$dir/plugin.php";
464466
if (is_file($path)) {
465-
$fileToLoad = true;
466-
include_once $path;
467-
$pluginDir = $dir;
467+
$plugin_file = $path;
468468
break;
469469
}
470470
}
471471

472+
if ($plugin_file) {
473+
$fileToLoad = true;
474+
require $plugin_file;
475+
}
476+
472477
if (isset($plugin_info['plugin_class']) && class_exists($plugin_info['plugin_class'], false)) {
473478
$cls = $plugin_info['plugin_class'];
474479
$instance = method_exists($cls, 'create') ? $cls::create() : new $cls();

0 commit comments

Comments
 (0)