From 6747b18b7555a489883f2041d64bf765b78cc07b Mon Sep 17 00:00:00 2001 From: Miguel Dantas Date: Sun, 1 Sep 2019 00:40:33 +0100 Subject: [PATCH] [PLUGINS] Added UnQueue, a new default plugin which does all actions immediately --- lib/queue/queuemanager.php | 15 ++---- lib/util/default.php | 1 + plugins/UnQueue/README | 14 ++++++ plugins/UnQueue/UnQueuePlugin.php | 48 +++++++++++++++++++ .../UnQueue/classes/UnQueueManager.php | 0 5 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 plugins/UnQueue/README create mode 100644 plugins/UnQueue/UnQueuePlugin.php rename lib/queue/unqueuemanager.php => plugins/UnQueue/classes/UnQueueManager.php (100%) diff --git a/lib/queue/queuemanager.php b/lib/queue/queuemanager.php index 10310fd43b..e73211a08b 100644 --- a/lib/queue/queuemanager.php +++ b/lib/queue/queuemanager.php @@ -59,18 +59,9 @@ abstract class QueueManager extends IoManager if (empty(self::$qm)) { if (Event::handle('StartNewQueueManager', array(&self::$qm))) { - $enabled = common_config('queue', 'enabled'); - $type = common_config('queue', 'subsystem'); - - if (!$enabled) { - // does everything immediately - self::$qm = new UnQueueManager(); - } else { - switch ($type) { - default: - throw new ServerException("No queue manager class for type '$type'"); - } - } + common_log(LOG_ERR, 'Some form of queue manager must be active' . + '(UnQueue does everything immediately and is the default)'); + throw new ServerException('Some form of queue manager must be active'); } } diff --git a/lib/util/default.php b/lib/util/default.php index 1de401d090..dfefaf2958 100644 --- a/lib/util/default.php +++ b/lib/util/default.php @@ -361,6 +361,7 @@ $default = 'Poll' => [], 'SimpleCaptcha' => [], 'TagSub' => [], + 'UnQueue' => [], 'WebFinger' => [], ], 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories diff --git a/plugins/UnQueue/README b/plugins/UnQueue/README new file mode 100644 index 0000000000..ed90e921cd --- /dev/null +++ b/plugins/UnQueue/README @@ -0,0 +1,14 @@ +UnQueuePlugin wraps the UnQueueManager class which is a queue manager that does all work immediately. + +Installation +============ + +This plugin is enabled by default and cannot be disabled unless another queue manager is in use. +Disabling is not necessary but recommended in such cases. + +Example +======= + +In config.php + +addPlugin('UnQueue'); \ No newline at end of file diff --git a/plugins/UnQueue/UnQueuePlugin.php b/plugins/UnQueue/UnQueuePlugin.php new file mode 100644 index 0000000000..1c6822a075 --- /dev/null +++ b/plugins/UnQueue/UnQueuePlugin.php @@ -0,0 +1,48 @@ +. + +/** + * Immediate action queue + * + * @package GNUsocial + * @author Miguel Dantas + * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +defined('GNUSOCIAL') || die(); + +class UnQueuePlugin extends Plugin +{ + const PLUGIN_VERSION = '0.0.1'; + + public function onStartNewQueueManager(?QueueManager &$qm) + { + $qm = new UnQueueManager(); + return false; + } + + public function onPluginVersion(array &$versions): bool + { + $versions[] = array('name' => 'UnQueue', + 'version' => self::PLUGIN_VERSION, + 'author' => 'Miguel Dantas', + 'description' => + // TRANS: Plugin description. + _m('Plugin using the database as a backend for GNU social queues')); + return true; + } +}; diff --git a/lib/queue/unqueuemanager.php b/plugins/UnQueue/classes/UnQueueManager.php similarity index 100% rename from lib/queue/unqueuemanager.php rename to plugins/UnQueue/classes/UnQueueManager.php