Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Hotfix/v1.0.4 #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ enabled:
- method_separation
- native_function_casing
- new_with_braces
- no_alias_functions
- no_blank_lines_after_class_opening
- no_blank_lines_after_phpdoc
- no_blank_lines_before_namespace
Expand All @@ -30,7 +29,6 @@ enabled:
- no_trailing_comma_in_list_call
- no_trailing_comma_in_singleline_array
- no_unneeded_control_parentheses
- no_unreachable_default_argument_value
- no_unused_imports
- no_useless_else
- no_useless_return
Expand Down
28 changes: 14 additions & 14 deletions Classes/ajax/class.tx_caretaker_Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public function getModuleUrl()
break;
}
if (VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
) {
$moduleUrl = 'alt_doc.php?edit[' . $table . '][' . (int)$storagePid . ']=new&' . http_build_query(
array('defVals' => $defaultValues)
);
array('defVals' => $defaultValues)
);
} else {
$moduleUrl = BackendUtility::getModuleUrl(
'record_edit',
Expand All @@ -110,8 +110,8 @@ public function getModuleUrl()
break;
case 'edit':
if (VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
) {
$moduleUrl = 'alt_doc.php?edit[' . $table . '][' . (int)$node . ']=edit';
} else {
Expand All @@ -126,13 +126,13 @@ public function getModuleUrl()
break;
case 'hide':
if (VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
) {
$moduleUrl = 'tce_db.php?data[' . $table . '][' . $node . '][hidden]=1' . BackendUtility::getUrlToken('tceAction');
} elseif (VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.6.0')
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.6.0')
) {
$moduleUrl = BackendUtility::getAjaxUrl(
'DataHandler::process',
Expand All @@ -148,13 +148,13 @@ public function getModuleUrl()
case
'unhide':
if (VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.0.0')
) {
$moduleUrl = 'tce_db.php?data[' . $table . '][' . $node . '][hidden]=0' . BackendUtility::getUrlToken('tceAction');
} elseif (VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.6.0')
VersionNumberUtility::getNumericTypo3Version()
) < VersionNumberUtility::convertVersionNumberToInteger('7.6.0')
) {
$moduleUrl = BackendUtility::getAjaxUrl(
'DataHandler::process',
Expand Down
3 changes: 2 additions & 1 deletion Classes/nodes/class.tx_caretaker_AggregatorNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ public function getStrategies()
's.*',
tx_caretaker_Constants::table_Strategies . ' s,' . tx_caretaker_Constants::relationTable_Node2Strategy . ' rel',
'rel.uid_node=' . $this->getUid() . ' AND rel.node_table=\'' . $this->getStorageTable() . '\' AND rel.uid_strategy=s.uid' .
' AND s.deleted = 0 AND s.hidden = 0');
' AND s.deleted = 0 AND s.hidden = 0'
);
}
if ($this->getParent()) {
$strategies = array_merge($strategies, $this->getParent()->getStrategies());
Expand Down
18 changes: 10 additions & 8 deletions Classes/repositories/class.tx_caretaker_NodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,17 @@ public function getTestByUid($uid, $parent = false, $show_hidden = false)
if (!$show_hidden) {
$hidden = ' AND hidden=0 ';
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_caretaker_test.*, (
SELECT GROUP_CONCAT(r.id)
FROM tx_caretaker_roles r, tx_caretaker_test_roles_mm mm
WHERE mm.uid_local = tx_caretaker_test.uid
AND r.uid = mm.uid_foreign
AND deleted = 0 ' . $hidden . '
) as roles_ids',
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_caretaker_test.*, (
SELECT GROUP_CONCAT(r.id)
FROM tx_caretaker_roles r, tx_caretaker_test_roles_mm mm
WHERE mm.uid_local = tx_caretaker_test.uid
AND r.uid = mm.uid_foreign
AND deleted = 0 ' . $hidden . '
) as roles_ids',
'tx_caretaker_test',
'deleted=0 ' . $hidden . ' AND uid=' . (int)$uid);
'deleted=0 ' . $hidden . ' AND uid=' . (int)$uid
);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
if ($row) {
$test = $this->dbrow2test($row, $parent);
Expand Down
28 changes: 20 additions & 8 deletions Classes/services/class.tx_caretaker_TestServiceRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* $Id: class.tx_caretaker_TestServiceBase.php 43817 2011-02-18 11:29:43Z etobi.de $
*/

use TYPO3\CMS\Core\Service\AbstractService;

/**
* Base strategy for running test services for a test node.
* A custom implementation could be used to clus
Expand All @@ -44,7 +46,7 @@
* @author Tobias Liebig <[email protected]>
*
*/
class tx_caretaker_TestServiceRunner extends \TYPO3\CMS\Core\Service\AbstractService
class tx_caretaker_TestServiceRunner extends AbstractService
{
/**
* Run a test service for the given test node
Expand All @@ -66,7 +68,7 @@ public function runTestService($testService, $node, $options)

return $latestTestResult;
}
return $this->executeTestServiceRun($testService, $node, $latestTestResult, $options);
return $this->executeTestServiceRun($testService, $node, $latestTestResult);
}

/**
Expand Down Expand Up @@ -125,17 +127,19 @@ protected function shouldReturnLatestResult($node, $latestTestResult, $options)
* @param tx_caretaker_TestServiceInterface $testService
* @param tx_caretaker_TestNode $node
* @param tx_caretaker_NodeResult $latestTestResult
* @param array $options
* @return tx_caretaker_NodeResult
*/
protected function executeTestServiceRun($testService, $node, $latestTestResult, $options)
protected function executeTestServiceRun($testService, $node, $latestTestResult)
{
// check whether the test can be executed
if ($testService && $testService->isExecutable()) {
try {
$result = $testService->runTest();
} catch (Exception $e) {
$result = tx_caretaker_TestResult::create(tx_caretaker_Constants::state_error, 0, '{LLL:EXT:caretaker/locallang_fe.xml:service_exception}' . $e->getMessage);
throw new RuntimeException(
'Execution of Caretaker TestService failed with: ' . $e->getMessage(),
1605201669
);
}

// retry if not ok and retrying is enabled
Expand All @@ -147,11 +151,17 @@ protected function executeTestServiceRun($testService, $node, $latestTestResult,
try {
$result = $testService->runTest();
} catch (Exception $e) {
$result = tx_caretaker_TestResult::create(tx_caretaker_Constants::state_error, 0, '{LLL:EXT:caretaker/locallang_fe.xml:service_exception}' . $e->getMessage);
throw new RuntimeException(
'Execution of Caretaker TestService failed with: ' . $e->getMessage(),
1605201757
);
}
$round++;
}
$result->addSubMessage(new tx_caretaker_ResultMessage('LLL:EXT:caretaker/locallang_fe.xml:retry_info', array('number' => $round)));
$result->addSubMessage(new tx_caretaker_ResultMessage(
'LLL:EXT:caretaker/locallang_fe.xml:retry_info',
array('number' => $round)
));
}

// save to repository after reading the previous result
Expand All @@ -164,7 +174,9 @@ protected function executeTestServiceRun($testService, $node, $latestTestResult,
return $result;
}
$result = tx_caretaker_TestResult::undefined();
$result->addSubMessage(new tx_caretaker_ResultMessage('test service was not executable this time so the cached result is used'));
$result->addSubMessage(new tx_caretaker_ResultMessage(
'test service was not executable this time so the cached result is used'
));
$node->notify('cachedTestResult', $result, $latestTestResult);

return $latestTestResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function addNotification($event, $node, $result = null, $lastResult = nul
'node' => $node,
'result' => $result,
'lastResult' => $lastResult,
));
)
);

if ($config['stop']) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ public function addNotification($notification, $overrideConfig)
$config = $this->getConfig($overrideConfig);

$line = implode(
' ',
array(
date('Y-m-d H:i:s'),
($notification['node'] instanceof tx_caretaker_AbstractNode ? $notification['node']->getInstance()->getTitle() : '-'),
($notification['node'] instanceof tx_caretaker_AbstractNode ? '[' . $notification['node']->getCaretakerNodeId() . ']' : '-'),
$notification['node']->getTitle(),
($notification['lastResult'] instanceof tx_caretaker_TestResult ? $notification['lastResult']->getLocallizedStateInfo() : '-'),
'->',
($notification['result'] instanceof tx_caretaker_TestResult ? $notification['result']->getLocallizedStateInfo() : '-'),
)
) . chr(10);
' ',
array(
date('Y-m-d H:i:s'),
($notification['node'] instanceof tx_caretaker_AbstractNode ? $notification['node']->getInstance()->getTitle() : '-'),
($notification['node'] instanceof tx_caretaker_AbstractNode ? '[' . $notification['node']->getCaretakerNodeId() . ']' : '-'),
$notification['node']->getTitle(),
($notification['lastResult'] instanceof tx_caretaker_TestResult ? $notification['lastResult']->getLocallizedStateInfo() : '-'),
'->',
($notification['result'] instanceof tx_caretaker_TestResult ? $notification['result']->getLocallizedStateInfo() : '-'),
)
) . chr(10);

$fileHandle = fopen($config['filePath'], 'a');
fwrite($fileHandle, $line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ public function addNotification($event, $node, $result = null, $lastResult = nul
$this->recipients_messages[$recipientId]['num_due']++;
break;
}
array_unshift($this->recipients_messages[$recipientId]['messages'],
array_unshift(
$this->recipients_messages[$recipientId]['messages'],
'*' . ($lastResult ? $lastResult->getLocallizedStateInfo() . '->' : '') . $result->getLocallizedStateInfo() . ' ' . $node->getInstance()->getTitle() . ':' . $node->getTitle() . '* ' . $node->getCaretakerNodeId() . chr(10) . chr(10) .
$result->getLocallizedInfotext() . chr(10) .
str_replace('###', $node->getCaretakerNodeId(), $this->mail_link) . chr(10)
Expand Down
30 changes: 20 additions & 10 deletions Tests/Unit/AggregatorResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,33 @@ public function test_comparisonOfAggreagtorResults()
$this->assertTrue($result->isDifferent($compareResult), 'result with other state is not equal');

$compareResult = \tx_caretaker_AggregatorResult::create(\tx_caretaker_Constants::state_undefined, 0, 0, 0, 0);
$this->assertTrue($result->equals($compareResult),
'result with state undefined and all errorNumbers 0 is equal to empty result');
$this->assertTrue(
$result->equals($compareResult),
'result with state undefined and all errorNumbers 0 is equal to empty result'
);

$compareResult = \tx_caretaker_AggregatorResult::create(\tx_caretaker_Constants::state_undefined, 1, 0, 0, 0);
$this->assertFalse($result->equals($compareResult),
'result with state undefined and but numUndefined = 1 is not equal to empty result');
$this->assertFalse(
$result->equals($compareResult),
'result with state undefined and but numUndefined = 1 is not equal to empty result'
);

$compareResult = \tx_caretaker_AggregatorResult::create(\tx_caretaker_Constants::state_undefined, 0, 1, 0, 0);
$this->assertFalse($result->equals($compareResult),
'result with state undefined and but numOK = 1 is not equal to empty result');
$this->assertFalse(
$result->equals($compareResult),
'result with state undefined and but numOK = 1 is not equal to empty result'
);

$compareResult = \tx_caretaker_AggregatorResult::create(\tx_caretaker_Constants::state_undefined, 0, 0, 1, 0);
$this->assertFalse($result->equals($compareResult),
'result with state undefined and but numWarning = 1 is not equal to empty result');
$this->assertFalse(
$result->equals($compareResult),
'result with state undefined and but numWarning = 1 is not equal to empty result'
);

$compareResult = \tx_caretaker_AggregatorResult::create(\tx_caretaker_Constants::state_undefined, 0, 0, 0, 1);
$this->assertFalse($result->equals($compareResult),
'result with state undefined and but numError = 1 is not equal to empty result');
$this->assertFalse(
$result->equals($compareResult),
'result with state undefined and but numError = 1 is not equal to empty result'
);
}
}
Loading