From 97d4fe5d3c6d5fcb0454126a558ab89417a6c4ed Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Fri, 10 Aug 2018 12:10:23 +0200 Subject: [PATCH] Enh: Added queue clear option at Administration - Information --- protected/humhub/docs/CHANGELOG.md | 1 + .../controllers/InformationController.php | 18 ++++++++++++++---- .../views/information/background-jobs.php | 11 +++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 6647ee772f..6c31ce5763 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -8,6 +8,7 @@ HumHub Change Log - Fix: Disabled Notification E-Mails for installation sample contents - Fix: No e-mail summary immediately after installation - Enh: Added queuing for search updates of commments +- Enh: Added queue clear option at Administration - Information 1.3.1 (August 7, 2018) diff --git a/protected/humhub/modules/admin/controllers/InformationController.php b/protected/humhub/modules/admin/controllers/InformationController.php index acc15e99e2..95b375f17a 100644 --- a/protected/humhub/modules/admin/controllers/InformationController.php +++ b/protected/humhub/modules/admin/controllers/InformationController.php @@ -11,10 +11,12 @@ namespace humhub\modules\admin\controllers; use humhub\modules\admin\components\Controller; use humhub\modules\admin\components\DatabaseInfo; use humhub\modules\admin\libs\HumHubAPI; +use humhub\modules\queue\driver\MySQL; use humhub\modules\queue\helpers\QueueHelper; use humhub\modules\queue\interfaces\QueueInfoInterface; use humhub\modules\search\jobs\RebuildIndex; use ReflectionClass; +use ReflectionException; use Yii; /** @@ -105,6 +107,15 @@ class InformationController extends Controller $queue = Yii::$app->queue; + $canClearQueue = false; + if ($queue instanceof MySQL) { + $canClearQueue = true; + $queue->clear(); + if (Yii::$app->request->isPost && Yii::$app->request->get('clearQueue') == 1) { + $this->view->setStatusMessage('success', Yii::t('AdminModule.information', 'Queue successfully cleared.')); + } + } + $waitingJobs = null; $delayedJobs = null; $doneJobs = null; @@ -122,11 +133,10 @@ class InformationController extends Controller try { $reflect = new ReflectionClass($queue); $driverName = $reflect->getShortName(); - } catch (\ReflectionException $e) { + } catch (ReflectionException $e) { Yii::error('Could not determine queue driver: '. $e->getMessage()); } - return $this->render('background-jobs', [ 'lastRunHourly' => $lastRunHourly, 'lastRunDaily' => $lastRunDaily, @@ -134,8 +144,8 @@ class InformationController extends Controller 'delayedJobs' => $delayedJobs, 'doneJobs' => $doneJobs, 'reservedJobs' => $reservedJobs, - 'driverName' => $driverName - + 'driverName' => $driverName, + 'canClearQueue' => $canClearQueue ]); } diff --git a/protected/humhub/modules/admin/views/information/background-jobs.php b/protected/humhub/modules/admin/views/information/background-jobs.php index b5b4b70fff..a5e79d7b63 100644 --- a/protected/humhub/modules/admin/views/information/background-jobs.php +++ b/protected/humhub/modules/admin/views/information/background-jobs.php @@ -8,8 +8,11 @@ * @var int|null $delayedJobs * @var int|null $doneJobs * @var int|null $reservedJobs + * @var boolean $canClearQueue */ +use humhub\widgets\Button; + if (empty($lastRunHourly)) { $lastRunHourly = "" . Yii::t('AdminModule.information', 'Never') . ""; } else { @@ -39,6 +42,13 @@ if (empty($lastRunDaily)) {
+ + link(['background-jobs', 'clearQueue' => 1]) + ->options(['data-method' => 'POST']) + ->xs()->right(); + ?> + Queue Status'); ?>
@@ -61,6 +71,7 @@ if (empty($lastRunDaily)) {


+