summaryrefslogtreecommitdiff
path: root/classes/pluginhost.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/pluginhost.php')
-rwxr-xr-xclasses/pluginhost.php39
1 files changed, 36 insertions, 3 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index ab26780c7..bdbecca13 100755
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -339,10 +339,13 @@ class PluginHost {
*/
function chain_hooks_callback(string $hook, Closure $callback, &...$args): void {
$method = strtolower((string)$hook);
+ $scope = Tracer::start(__METHOD__, ['hook' => $hook]);
foreach ($this->get_hooks((string)$hook) as $plugin) {
//Debug::log("invoking: " . get_class($plugin) . "->$hook()", Debug::$LOG_VERBOSE);
+ $p_scope = Tracer::start("$hook - " . get_class($plugin));
+
try {
if ($callback($plugin->$method(...$args), $plugin))
break;
@@ -351,7 +354,11 @@ class PluginHost {
} catch (Error $err) {
user_error($err, E_USER_WARNING);
}
+
+ $p_scope->close();
}
+
+ $scope->close();
}
/**
@@ -431,6 +438,8 @@ class PluginHost {
* @param PluginHost::KIND_* $kind
*/
function load(string $classlist, int $kind, int $owner_uid = null, bool $skip_init = false): void {
+ $scope = Tracer::start(__METHOD__);
+
$plugins = explode(",", $classlist);
$this->owner_uid = (int) $owner_uid;
@@ -439,18 +448,21 @@ class PluginHost {
$class = trim($class);
$class_file = strtolower(basename(clean($class)));
+ $p_scope = Tracer::start("loading $class_file");
+
// try system plugin directory first
$file = dirname(__DIR__) . "/plugins/$class_file/init.php";
if (!file_exists($file)) {
$file = dirname(__DIR__) . "/plugins.local/$class_file/init.php";
- if (!file_exists($file))
+ if (!file_exists($file)) {
+ $p_scope->close();
continue;
+ }
}
if (!isset($this->plugins[$class])) {
-
// WIP hack
// we can't catch incompatible method signatures via Throwable
// this also enables global tt-rss safe mode in case there are more plugins like this
@@ -464,6 +476,8 @@ class PluginHost {
$_SESSION["safe_mode"] = 1;
+ $p_scope->getSpan()->setTag('error', 'plugin is blacklisted');
+ $p_scope->close();
continue;
}
@@ -474,16 +488,21 @@ class PluginHost {
} catch (Error $err) {
user_error($err, E_USER_WARNING);
+
+ $p_scope->getSpan()->setTag('error', $err);
+ $p_scope->close();
continue;
}
if (class_exists($class) && is_subclass_of($class, "Plugin")) {
-
$plugin = new $class($this);
$plugin_api = $plugin->api_version();
if ($plugin_api < self::API_VERSION) {
user_error("Plugin $class is not compatible with current API version (need: " . self::API_VERSION . ", got: $plugin_api)", E_USER_WARNING);
+
+ $p_scope->getSpan()->setTag('error', 'plugin is not compatible with API version');
+ $p_scope->close();
continue;
}
@@ -492,6 +511,8 @@ class PluginHost {
_bind_textdomain_codeset($class, "UTF-8");
}
+ $i_scope = Tracer::start('init and register plugin');
+
try {
switch ($kind) {
case $this::KIND_SYSTEM:
@@ -516,11 +537,17 @@ class PluginHost {
} catch (Error $err) {
user_error($err, E_USER_WARNING);
}
+
+ $i_scope->close();
+
}
}
+ $p_scope->close();
}
$this->load_data();
+
+ $scope->close();
}
function is_system(Plugin $plugin): bool {
@@ -613,6 +640,8 @@ class PluginHost {
}
private function load_data(): void {
+ $scope = Tracer::start(__METHOD__);
+
if ($this->owner_uid && !$this->data_loaded && get_schema_version() > 100) {
$sth = $this->pdo->prepare("SELECT name, content FROM ttrss_plugin_storage
WHERE owner_uid = ?");
@@ -624,10 +653,13 @@ class PluginHost {
$this->data_loaded = true;
}
+
+ $scope->close();
}
private function save_data(string $plugin): void {
if ($this->owner_uid) {
+ $scope = Tracer::start(__METHOD__);
if (!$this->pdo_data)
$this->pdo_data = Db::instance()->pdo_connect();
@@ -655,6 +687,7 @@ class PluginHost {
}
$this->pdo_data->commit();
+ $scope->close();
}
}