pluginhost: remove namespace classloader, plugins should use composer instead

This commit is contained in:
Andrew Dolgov 2021-03-02 13:38:03 +03:00
parent 08ff629af5
commit 86b12fc06c
1 changed files with 5 additions and 27 deletions

View File

@ -274,16 +274,14 @@ class PluginHost {
$class = trim($class);
$class_file = strtolower(basename(clean($class)));
if (!is_dir(__DIR__ . "/../plugins/$class_file") &&
!is_dir(__DIR__ . "/../plugins.local/$class_file")) continue;
// try system plugin directory first
$file = __DIR__ . "/../plugins/$class_file/init.php";
$vendor_dir = __DIR__ . "/../plugins/$class_file/vendor";
$file = dirname(__DIR__) . "/plugins/$class_file/init.php";
if (!file_exists($file)) {
$file = __DIR__ . "/../plugins.local/$class_file/init.php";
$vendor_dir = __DIR__ . "/../plugins.local/$class_file/vendor";
$file = dirname(__DIR__) . "/plugins.local/$class_file/init.php";
if (!file_exists($file))
continue;
}
if (!isset($this->plugins[$class])) {
@ -296,27 +294,7 @@ class PluginHost {
if (class_exists($class) && is_subclass_of($class, "Plugin")) {
// register plugin autoloader if necessary, for namespaced classes ONLY
// layout corresponds to tt-rss main /vendor/author/Package/Class.php
if (file_exists($vendor_dir)) {
spl_autoload_register(function($class) use ($vendor_dir) {
if (strpos($class, '\\') !== false) {
list ($namespace, $class_name) = explode('\\', $class, 2);
if ($namespace && $class_name) {
$class_file = "$vendor_dir/$namespace/" . str_replace('\\', '/', $class_name) . ".php";
if (file_exists($class_file))
require_once $class_file;
}
}
});
}
$plugin = new $class($this);
$plugin_api = $plugin->api_version();
if ($plugin_api < self::API_VERSION) {