diff options
Diffstat (limited to 'classes/pluginhost.php')
-rwxr-xr-x | classes/pluginhost.php | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 6158880f2..3ff658918 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -1,6 +1,9 @@ <?php class PluginHost { private $pdo; + /* separate handle for plugin data so transaction while saving wouldn't clash with possible main + tt-rss code transactions; only initialized when first needed */ + private $pdo_data; private $hooks = array(); private $plugins = array(); private $handlers = array(); @@ -62,6 +65,9 @@ class PluginHost { const HOOK_ARTICLE_IMAGE = 42; const HOOK_FEED_TREE = 43; const HOOK_IFRAME_WHITELISTED = 44; + const HOOK_ENCLOSURE_IMPORTED = 45; + const HOOK_HEADLINES_CUSTOM_SORT_MAP = 46; + const HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE = 47; const KIND_ALL = 1; const KIND_SYSTEM = 2; @@ -73,7 +79,6 @@ class PluginHost { function __construct() { $this->pdo = Db::pdo(); - $this->storage = array(); } @@ -150,7 +155,7 @@ class PluginHost { foreach (array_keys($this->hooks[$type]) as $prio) { $key = array_search($sender, $this->hooks[$type][$prio]); - if ($key !== FALSE) { + if ($key !== false) { unset($this->hooks[$type][$prio][$key]); } } @@ -188,7 +193,7 @@ class PluginHost { foreach ($plugins as $class) { $class = trim($class); - $class_file = strtolower(clean_filename($class)); + $class_file = strtolower(basename(clean($class))); if (!is_dir(__DIR__."/../plugins/$class_file") && !is_dir(__DIR__."/../plugins.local/$class_file")) continue; @@ -213,7 +218,7 @@ class PluginHost { if (file_exists($vendor_dir)) { spl_autoload_register(function($class) use ($vendor_dir) { - if (strpos($class, '\\') !== FALSE) { + if (strpos($class, '\\') !== false) { list ($namespace, $class_name) = explode('\\', $class, 2); if ($namespace && $class_name) { @@ -230,8 +235,8 @@ class PluginHost { $plugin_api = $plugin->api_version(); - if ($plugin_api < PluginHost::API_VERSION) { - user_error("Plugin $class is not compatible with current API version (need: " . PluginHost::API_VERSION . ", got: $plugin_api)", E_USER_WARNING); + 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); continue; } @@ -361,9 +366,13 @@ class PluginHost { private function save_data($plugin) { if ($this->owner_uid) { - $this->pdo->beginTransaction(); - $sth = $this->pdo->prepare("SELECT id FROM ttrss_plugin_storage WHERE + if (!$this->pdo_data) + $this->pdo_data = Db::instance()->pdo_connect(); + + $this->pdo_data->beginTransaction(); + + $sth = $this->pdo_data->prepare("SELECT id FROM ttrss_plugin_storage WHERE owner_uid= ? AND name = ?"); $sth->execute([$this->owner_uid, $plugin]); @@ -373,18 +382,18 @@ class PluginHost { $content = serialize($this->storage[$plugin]); if ($sth->fetch()) { - $sth = $this->pdo->prepare("UPDATE ttrss_plugin_storage SET content = ? + $sth = $this->pdo_data->prepare("UPDATE ttrss_plugin_storage SET content = ? WHERE owner_uid= ? AND name = ?"); $sth->execute([(string)$content, $this->owner_uid, $plugin]); } else { - $sth = $this->pdo->prepare("INSERT INTO ttrss_plugin_storage + $sth = $this->pdo_data->prepare("INSERT INTO ttrss_plugin_storage (name,owner_uid,content) VALUES (?, ?, ?)"); $sth->execute([$plugin, $this->owner_uid, (string)$content]); } - $this->pdo->commit(); + $this->pdo_data->commit(); } } |