Skip to content

Commit

Permalink
[TASK] Cleanup from PHPStan baseline (tomasnorre#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnorre committed Mar 30, 2021
1 parent 53e2fa0 commit b64f757
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 722 deletions.
5 changes: 5 additions & 0 deletions Classes/Backend/RequestForm/StartRequestForm.php
Expand Up @@ -239,6 +239,11 @@ private function getScheduledTime(string $time)
$scheduledTime = time();
break;
}

if (! $scheduledTime) {
return time();
}

return $scheduledTime;
}
}
29 changes: 14 additions & 15 deletions Classes/Controller/CrawlerController.php
Expand Up @@ -1228,26 +1228,25 @@ public function readUrl($queueId, $force = false)
/** @var JsonCompatibilityConverter $jsonCompatibilityConverter */
$jsonCompatibilityConverter = GeneralUtility::makeInstance(JsonCompatibilityConverter::class);
$resultData = $jsonCompatibilityConverter->convert($result['content']);
}

//atm there's no need to point to specific pollable extensions
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pollSuccess'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pollSuccess'] as $pollable) {
// only check the success value if the instruction is runnig
// it is important to name the pollSuccess key same as the procInstructions key
if (is_array($resultData['parameters']['procInstructions'])
&& in_array(
$pollable,
$resultData['parameters']['procInstructions'], true
)
) {
if (! empty($resultData['success'][$pollable]) && $resultData['success'][$pollable]) {
$ret |= self::CLI_STATUS_POLLABLE_PROCESSED;
//atm there's no need to point to specific pollable extensions
if (is_array($resultData) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pollSuccess'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pollSuccess'] as $pollable) {
// only check the success value if the instruction is runnig
// it is important to name the pollSuccess key same as the procInstructions key
if (is_array($resultData['parameters']['procInstructions'])
&& in_array(
$pollable,
$resultData['parameters']['procInstructions'], true
)
) {
if (! empty($resultData['success'][$pollable]) && $resultData['success'][$pollable]) {
$ret |= self::CLI_STATUS_POLLABLE_PROCESSED;
}
}
}
}
}

// Set result in log which also denotes the end of the processing of this entry.
$field_array = ['result_data' => json_encode($result)];

Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Model/ProcessCollection.php
Expand Up @@ -39,7 +39,7 @@ class ProcessCollection extends \ArrayObject
{
/**
* Method to retrieve an element from the collection.
*
* @param mixed $index
* @throws NoIndexFoundException
*/
public function offsetGet($index): Process
Expand All @@ -53,6 +53,7 @@ public function offsetGet($index): Process
/**
* Method to add an element to the collection-
*
* @param mixed $index
* @param Process $subject
* @throws \InvalidArgumentException
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/QueueRepository.php
Expand Up @@ -511,7 +511,7 @@ public function cleanUpOldQueueEntries(): void
}
}

public function fetchRecordsToBeCrawled(int $countInARun)
public function fetchRecordsToBeCrawled(int $countInARun): array
{
$queryBuilderSelect = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->tableName);
return $queryBuilderSelect
Expand Down
14 changes: 7 additions & 7 deletions Classes/Service/ProcessService.php
Expand Up @@ -208,8 +208,10 @@ public function startProcess(): bool
$completePath = '(' . $this->getCrawlerCliPath() . ' &) > /dev/null';
}

$fileHandler = CommandUtility::exec($completePath);
if ($fileHandler === false) {
$output = null;
$returnValue = 0;
CommandUtility::exec($completePath, $output, $returnValue);
if ($returnValue !== 0) {
throw new ProcessException('could not start process!');
}
for ($i = 0; $i < 10; $i++) {
Expand Down Expand Up @@ -273,11 +275,9 @@ private function startRequiredProcesses()
}
for ($i = 0; $i < $startProcessCount; $i++) {
usleep(100);
if ($this->startProcess()) {
if ($this->verbose) {
echo '.';
$ret = true;
}
if ($this->startProcess() && $this->verbose) {
echo '.';
$ret = true;
}
}
if ($this->verbose) {
Expand Down

0 comments on commit b64f757

Please sign in to comment.