Skip to content

Commit 045bc00

Browse files
authored
Merge pull request dokuwiki#4059 from dokuwiki/loader
Refactor autoloading, fix dokuwiki#4048
2 parents 2f624be + a0e3c23 commit 045bc00

File tree

3 files changed

+262
-129
lines changed

3 files changed

+262
-129
lines changed

inc/Extension/PluginController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct()
2828
{
2929
$this->loadConfig();
3030
$this->populateMasterList();
31+
$this->initAutoloaders();
3132
}
3233

3334
/**
@@ -394,4 +395,21 @@ protected function negate($input)
394395
{
395396
return !(bool)$input;
396397
}
398+
399+
/**
400+
* Initialize vendor autoloaders for all plugins that have them
401+
*/
402+
protected function initAutoloaders()
403+
{
404+
$plugins = $this->getList();
405+
foreach ($plugins as $plugin) {
406+
if (file_exists(DOKU_PLUGIN . $plugin . '/vendor/autoload.php')) {
407+
try {
408+
require_once(DOKU_PLUGIN . $plugin . '/vendor/autoload.php');
409+
} catch (\Throwable $e) {
410+
ErrorHandler::showExceptionMsg($e, sprintf('Failed to init plugin %s autoloader', $plugin));
411+
}
412+
}
413+
}
414+
}
397415
}

inc/init.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ function_exists('ob_gzhandler') &&
202202
global $plugin_controller_class, $plugin_controller;
203203
if (empty($plugin_controller_class)) $plugin_controller_class = PluginController::class;
204204

205-
// load libraries
206-
require_once(DOKU_INC . 'vendor/autoload.php');
205+
// autoloader
207206
require_once(DOKU_INC . 'inc/load.php');
208207

209208
// from now on everything is an exception

0 commit comments

Comments
 (0)