Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all Drush constant references #222

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public function __construct(State $state, UpdatesProcessor $updatesProcessor) {
/**
* Processes OpenLeg update blocks to queue subscription emails.
*
* NOTE: return code is a shell success (0)/fail (1).
*
* @param array $options
* An associative array of options whose values come from cli, aliases,
* config, etc.
Expand All @@ -81,22 +83,24 @@ public function __construct(State $state, UpdatesProcessor $updatesProcessor) {
*
* @aliases nysbn-pu
*/
public function processUpdates(array $options = [
'from' => NULL,
'to' => NULL,
'force' => FALSE,
]): int {
public function processUpdates(
array $options = [
'from' => NULL,
'to' => NULL,
'force' => FALSE,
],
): int {
$this->options = $this->resolveOptions($options);

// Check for a lock, and set the lock.
if ($has_lock = $this->getLock()) {
$this->logger()->warning("Process lock detected ...");
if (!$this->options['force']) {
$message = "Process lock in place since " .
date(Request::OPENLEG_TIME_SIMPLE, $has_lock) .
". Wait for release, or use option --force to ignore it.";
date(Request::OPENLEG_TIME_SIMPLE, $has_lock) .
". Wait for release, or use option --force to ignore it.";
$this->logger()->critical($message);
return DRUSH_FRAMEWORK_ERROR;
return 1;
}
$this->logger()->info("Ignoring lock because --force was used.");
}
Expand All @@ -108,7 +112,7 @@ public function processUpdates(array $options = [
$this->setState('last_run', $ts);
/* @phpstan-ignore-next-line */
$this->logger()->success(dt('Update processing complete.'));
return DRUSH_SUCCESS;
return 0;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion web/modules/custom/nys_sage/src/Commands/SageCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function __construct(SageLogger $sageLogger) {
/**
* Import objects from OpenLeg.
*
* NOTE: return code is a shell success (0)/fail (1).
*
* @option integer $max-age
* Overrides the module's configured max retention setting; number of days.
* @usage drush nys_sage:cron
Expand All @@ -46,7 +48,7 @@ public function sageLogCron(array $options = ['max-age' => NULL]): int {
else {
$this->sageLogger->expireEntries($max_age * $this->sageLogger::SAGE_ONE_DAY);
}
return DRUSH_SUCCESS;
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ protected function resolveQueues(string $queues): array {
* If no queues are specified, all registered queues will be processed. Each
* queue specified must be registered.
*
* NOTE: return code is a shell success (0)/fail (1).
*
* @param array $options
* An associative array of options whose values come from cli, aliases,
* config, etc.
Expand All @@ -85,11 +87,13 @@ protected function resolveQueues(string $queues): array {
*
* @aliases nysub-pq
*/
public function processQueues(array $options = [
'queues' => '',
'max_runtime' => NULL,
]): int {
$ret = DRUSH_SUCCESS;
public function processQueues(
array $options = [
'queues' => '',
'max_runtime' => NULL,
],
): int {
$ret = 0;
$queues = $this->resolveQueues($options['queues'] ?? '');
foreach ($queues as $one_queue) {
$this->logger()->info('Processing queue: @name', ['@name' => $one_queue]);
Expand All @@ -99,18 +103,18 @@ public function processQueues(array $options = [
$results = $queue->process($bedtime);
$this->logger()
->info(
"Completed processing for queue @name, @success success, @fail fail, @skip skipped",
[
'@success' => $results->getSuccess(),
'@fail' => $results->getFail(),
'@skip' => $results->getSkipped(),
]
);
"Completed processing for queue @name, @success success, @fail fail, @skip skipped",
[
'@success' => $results->getSuccess(),
'@fail' => $results->getFail(),
'@skip' => $results->getSkipped(),
]
);
}
catch (\Throwable $e) {
$this->logger()
->error("Queue @name failed to process, message:\n@msg", ['@msg' => $e->getMessage()]);
$ret = DRUSH_APPLICATION_ERROR;
$ret = 1;
}
}
return $ret;
Expand Down
Loading