@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class BaseController extends Controller |
| 24 | 24 | { |
| 25 | - public function sendRequestToBackendWorker($processor, $actionName, $payload = null, $modulename=''): void |
|
| 25 | + public function sendRequestToBackendWorker($processor, $actionName, $payload = null, $modulename = ''): void |
|
| 26 | 26 | { |
| 27 | 27 | $requestMessage = [ |
| 28 | 28 | 'processor' => $processor, |
| 29 | 29 | 'data' => $payload, |
| 30 | 30 | 'action' => $actionName |
| 31 | 31 | ]; |
| 32 | - if ($processor==='modules'){ |
|
| 32 | + if ($processor === 'modules') { |
|
| 33 | 33 | $requestMessage['module'] = $modulename; |
| 34 | 34 | } |
| 35 | 35 | try { |
| 36 | 36 | $message = json_encode($requestMessage, JSON_THROW_ON_ERROR); |
| 37 | - $response = $this->di->getShared('beanstalkConnection')->request($message, 30, 0); |
|
| 37 | + $response = $this->di->getShared('beanstalkConnection')->request($message, 30, 0); |
|
| 38 | 38 | if ($response !== false) { |
| 39 | 39 | $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR); |
| 40 | 40 | $this->response->setPayloadSuccess($response); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $this |
| 58 | 58 | ->response |
| 59 | - ->setPayloadError($this->response->getHttpCodeDescription($code) . ' ' . $description) |
|
| 59 | + ->setPayloadError($this->response->getHttpCodeDescription($code).' '.$description) |
|
| 60 | 60 | ->setStatusCode($code); |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $config = $this->di->get('config')->beanstalk; |
| 50 | 50 | $port = $config->port; |
| 51 | - if ( ! empty($this->port) && is_numeric($this->port)) { |
|
| 51 | + if (!empty($this->port) && is_numeric($this->port)) { |
|
| 52 | 52 | $port = $this->port; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | $this->queue->delete($job); |
| 103 | 103 | $job = null; |
| 104 | 104 | } |
| 105 | - } catch (Throwable $exception){ |
|
| 105 | + } catch (Throwable $exception) { |
|
| 106 | 106 | Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
| 107 | 107 | } finally { |
| 108 | - if ($job !== null){ |
|
| 108 | + if ($job !== null) { |
|
| 109 | 109 | $this->queue->bury($job); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ): Job { |
| 137 | 137 | $tube = str_replace("\\", '-', $tube); |
| 138 | 138 | // Change tube |
| 139 | - if ( ! empty($tube) && $this->tube !== $tube) { |
|
| 139 | + if (!empty($tube) && $this->tube !== $tube) { |
|
| 140 | 140 | $this->queue->useTube($tube); |
| 141 | 141 | } |
| 142 | 142 | $job_data = serialize($job_data); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | // Delete outdated jobs |
| 169 | 169 | while ($job = $this->queue->peekReady()) { |
| 170 | 170 | $jobStats = $this->queue->statsJob($job); |
| 171 | - if ($jobStats->age>$jobStats->timeout*2){ |
|
| 171 | + if ($jobStats->age > $jobStats->timeout * 2) { |
|
| 172 | 172 | $id = $job->getId(); |
| 173 | 173 | $this->queue->delete($job); |
| 174 | 174 | Util::sysLogMsg(__METHOD__, "Deleted outdated job with ID {$id} from {$tube}"); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | $this->queue->watchOnly('default'); |
| 178 | 178 | |
| 179 | - } catch (Throwable $exception){ |
|
| 179 | + } catch (Throwable $exception) { |
|
| 180 | 180 | Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | $start = microtime(true); |
| 209 | 209 | $job = null; |
| 210 | 210 | try { |
| 211 | - $job = $this->queue->reserveWithTimeout($timeout); |
|
| 212 | - } catch (Throwable $exception){ |
|
| 211 | + $job = $this->queue->reserveWithTimeout($timeout); |
|
| 212 | + } catch (Throwable $exception) { |
|
| 213 | 213 | Util::sysLogMsg(__METHOD__, 'Exception: '.$exception->getMessage()); |
| 214 | 214 | } |
| 215 | 215 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $requestFormTube = $stats['tube']; |
| 239 | 239 | $func = $this->subscriptions[$requestFormTube] ?? null; |
| 240 | 240 | |
| 241 | - if ($func===null){ |
|
| 241 | + if ($func === null) { |
|
| 242 | 242 | // Action not found |
| 243 | 243 | $this->queue->bury($job); |
| 244 | 244 | } else { |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | { |
| 29 | 29 | $managedCache = $this->di->get('managedCache'); |
| 30 | 30 | $lastTubesCheck = $managedCache->get('lastTubesCheck'); |
| 31 | - if ($lastTubesCheck === null){ |
|
| 31 | + if ($lastTubesCheck === null) { |
|
| 32 | 32 | $client = new BeanstalkClient(); |
| 33 | 33 | $client->cleanTubes(); |
| 34 | 34 | $managedCache->set('lastTubesCheck', time(), 600); |