diff --git a/.styleci.yml b/.styleci.yml index 9e76391b..5510a575 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -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 @@ -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 diff --git a/Classes/ajax/class.tx_caretaker_Utility.php b/Classes/ajax/class.tx_caretaker_Utility.php index 43711285..a1412b3b 100644 --- a/Classes/ajax/class.tx_caretaker_Utility.php +++ b/Classes/ajax/class.tx_caretaker_Utility.php @@ -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', @@ -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 { @@ -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', @@ -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', diff --git a/Classes/nodes/class.tx_caretaker_AggregatorNode.php b/Classes/nodes/class.tx_caretaker_AggregatorNode.php index 3fa210ec..c948d76c 100644 --- a/Classes/nodes/class.tx_caretaker_AggregatorNode.php +++ b/Classes/nodes/class.tx_caretaker_AggregatorNode.php @@ -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()); diff --git a/Classes/repositories/class.tx_caretaker_NodeRepository.php b/Classes/repositories/class.tx_caretaker_NodeRepository.php index c0b65bf5..ec4fd1d6 100644 --- a/Classes/repositories/class.tx_caretaker_NodeRepository.php +++ b/Classes/repositories/class.tx_caretaker_NodeRepository.php @@ -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); diff --git a/Classes/services/class.tx_caretaker_TestServiceRunner.php b/Classes/services/class.tx_caretaker_TestServiceRunner.php index 72f024ce..22e5b3c1 100644 --- a/Classes/services/class.tx_caretaker_TestServiceRunner.php +++ b/Classes/services/class.tx_caretaker_TestServiceRunner.php @@ -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 @@ -44,7 +46,7 @@ * @author Tobias Liebig * */ -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 @@ -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); } /** @@ -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 @@ -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 @@ -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; diff --git a/Classes/services/notifications/advanced/class.tx_caretaker_AdvancedNotificationService.php b/Classes/services/notifications/advanced/class.tx_caretaker_AdvancedNotificationService.php index fc3adca7..a45fad81 100644 --- a/Classes/services/notifications/advanced/class.tx_caretaker_AdvancedNotificationService.php +++ b/Classes/services/notifications/advanced/class.tx_caretaker_AdvancedNotificationService.php @@ -93,7 +93,8 @@ public function addNotification($event, $node, $result = null, $lastResult = nul 'node' => $node, 'result' => $result, 'lastResult' => $lastResult, - )); + ) + ); if ($config['stop']) { break; diff --git a/Classes/services/notifications/advanced/exitpoints/class.tx_caretaker_NotificationFileExitPoint.php b/Classes/services/notifications/advanced/exitpoints/class.tx_caretaker_NotificationFileExitPoint.php index 14e94dba..e2958554 100644 --- a/Classes/services/notifications/advanced/exitpoints/class.tx_caretaker_NotificationFileExitPoint.php +++ b/Classes/services/notifications/advanced/exitpoints/class.tx_caretaker_NotificationFileExitPoint.php @@ -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); diff --git a/Classes/services/notifications/class.tx_caretaker_SimpleMailNotificationService.php b/Classes/services/notifications/class.tx_caretaker_SimpleMailNotificationService.php index 6ee6a15f..e6504011 100644 --- a/Classes/services/notifications/class.tx_caretaker_SimpleMailNotificationService.php +++ b/Classes/services/notifications/class.tx_caretaker_SimpleMailNotificationService.php @@ -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) diff --git a/Tests/Unit/AggregatorResultTest.php b/Tests/Unit/AggregatorResultTest.php index 081fa32c..9b4cebbe 100644 --- a/Tests/Unit/AggregatorResultTest.php +++ b/Tests/Unit/AggregatorResultTest.php @@ -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' + ); } } diff --git a/Tests/Unit/HttpTestServiceTest.php b/Tests/Unit/HttpTestServiceTest.php index 5e3f5c26..0716e2c1 100644 --- a/Tests/Unit/HttpTestServiceTest.php +++ b/Tests/Unit/HttpTestServiceTest.php @@ -1,6 +1,7 @@ getMockBuilder('tx_caretaker_httpTestService') ->setMethods( - array('getTimeError', 'getTimeWarning', 'getExpectedReturnCode', 'getRequestQuery', 'getInstanceUrl')) + array('getTimeError', 'getTimeWarning', 'getExpectedReturnCode', 'getRequestQuery', 'getInstanceUrl') + ) ->getMock(); $this->setMethodReturnValue($stub, 'getTimeError', 200); @@ -70,9 +72,9 @@ public function testErrorIfNoQuery() private function setMethodReturnValue(&$stub, $method_name, $return_value) { $stub->expects($this->any()) - ->method($method_name) - ->with() - ->will($this->returnValue($return_value)); + ->method($method_name) + ->with() + ->will($this->returnValue($return_value)); } public function testEverythingWentFine() @@ -87,7 +89,8 @@ public function testEverythingWentFine() 'getRequestQuery', 'getInstanceUrl', 'executeCurlRequest', - )) + ) + ) ->getMock(); $this->setMethodReturnValue($stub, 'getTimeError', 20); @@ -95,7 +98,11 @@ public function testEverythingWentFine() $this->setMethodReturnValue($stub, 'getExpectedReturnCode', array(200)); $this->setMethodReturnValue($stub, 'getRequestQuery', true); $this->setMethodReturnValue($stub, 'getInstanceUrl', true); - $this->setMethodReturnValue($stub, 'executeCurlRequest', array(5, '', array('http_code' => 200, array()))); + $this->setMethodReturnValue( + $stub, + 'executeCurlRequest', + array(5, '', array('http_code' => 200, array())) + ); $result = $stub->runTest(); @@ -116,7 +123,8 @@ public function testWarningIfTimeoutIsReached() 'getRequestQuery', 'getInstanceUrl', 'executeCurlRequest', - )) + ) + ) ->getMock(); $this->setMethodReturnValue($stub, 'getTimeError', 20); @@ -124,7 +132,11 @@ public function testWarningIfTimeoutIsReached() $this->setMethodReturnValue($stub, 'getExpectedReturnCode', array(200)); $this->setMethodReturnValue($stub, 'getRequestQuery', true); $this->setMethodReturnValue($stub, 'getInstanceUrl', true); - $this->setMethodReturnValue($stub, 'executeCurlRequest', array(12, '', array('http_code' => 200, array()))); + $this->setMethodReturnValue( + $stub, + 'executeCurlRequest', + array(12, '', array('http_code' => 200, array())) + ); $result = $stub->runTest(); @@ -145,7 +157,8 @@ public function testErrorIfTimeoutIsReached() 'getRequestQuery', 'getInstanceUrl', 'executeCurlRequest', - )) + ) + ) ->getMock(); $this->setMethodReturnValue($stub, 'getTimeError', 20); @@ -153,7 +166,11 @@ public function testErrorIfTimeoutIsReached() $this->setMethodReturnValue($stub, 'getExpectedReturnCode', array(200)); $this->setMethodReturnValue($stub, 'getRequestQuery', true); $this->setMethodReturnValue($stub, 'getInstanceUrl', true); - $this->setMethodReturnValue($stub, 'executeCurlRequest', array(22, '', array('http_code' => 200, array()))); + $this->setMethodReturnValue( + $stub, + 'executeCurlRequest', + array(22, '', array('http_code' => 200, array())) + ); $result = $stub->runTest(); @@ -174,7 +191,8 @@ public function testErrorIfHttpStatusIsWrong() 'getRequestQuery', 'getInstanceUrl', 'executeCurlRequest', - )) + ) + ) ->getMock(); $this->setMethodReturnValue($stub, 'getTimeError', 20); @@ -182,7 +200,11 @@ public function testErrorIfHttpStatusIsWrong() $this->setMethodReturnValue($stub, 'getExpectedReturnCode', array(404)); $this->setMethodReturnValue($stub, 'getRequestQuery', true); $this->setMethodReturnValue($stub, 'getInstanceUrl', true); - $this->setMethodReturnValue($stub, 'executeCurlRequest', array(5, '', array('http_code' => 200, array()))); + $this->setMethodReturnValue( + $stub, + 'executeCurlRequest', + array(5, '', array('http_code' => 200, array())) + ); $result = $stub->runTest(); @@ -193,7 +215,7 @@ public function testErrorIfHttpStatusIsWrong() public function testHttpHeaderComparison() { - /** @var \PHPUnit_Framework_MockObject_MockObject|\tx_caretaker_httpTestService|\Caretaker\Caretaker\Tests\Unit\Stubs\HttpTestServiceStub $stub */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\tx_caretaker_httpTestService|HttpTestServiceStub $stub */ $stub = $this->getMockBuilder('\Caretaker\Caretaker\Tests\Unit\Stubs\HttpTestServiceStub') ->setMethods(array('getRequestQuery', 'getInstanceUrl')) ->getMock(); @@ -240,12 +262,12 @@ public function parseHeaderDateDataProvider() { $now = time(); return array( - array('Tue, 15 Nov 1994 08:12:31 GMT', '784887151'), - array('Mon, 14 Jul 2014 10:48:22 UTC', '1405334902'), - array('Tue, 15 Jul 2014 10:48:22 UTC', '1405421302'), - array('Sat, 15 Jul 2017 10:48:22 UTC', '1500115702'), - array('Sat, 15 Jul 2017 10:48:22 +0200', '1500108502'), - array(date(DATE_RFC1123, $now), $now), + array('Tue, 15 Nov 1994 08:12:31 GMT', '784887151'), + array('Mon, 14 Jul 2014 10:48:22 UTC', '1405334902'), + array('Tue, 15 Jul 2014 10:48:22 UTC', '1405421302'), + array('Sat, 15 Jul 2017 10:48:22 UTC', '1500115702'), + array('Sat, 15 Jul 2017 10:48:22 +0200', '1500108502'), + array(date(DATE_RFC1123, $now), $now), ); } @@ -256,7 +278,7 @@ public function parseHeaderDateDataProvider() */ public function testParseHeaderDate($dateString, $expectedDate) { - $subject = new \Caretaker\Caretaker\Tests\Unit\Stubs\HttpTestServiceStub(); + $subject = new HttpTestServiceStub(); $this->assertEquals($expectedDate, $subject->parseHeaderDate($dateString)); } } diff --git a/ext_tables.php b/ext_tables.php index c9082ef8..3d3b77ba 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -89,7 +89,10 @@ \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('txcaretakerNav', 'txcaretakerOverview', '', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'mod_overview/'); } else { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( - 'txcaretakerNav', '', '', '', + 'txcaretakerNav', + '', + '', + '', array( 'name' => 'txcaretakerNav', 'access' => 'user,group', @@ -98,7 +101,10 @@ ) ); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule( - 'txcaretakerNav', 'txcaretakerOverview', '', '', + 'txcaretakerNav', + 'txcaretakerOverview', + '', + '', array( 'name' => 'txcaretakerNav_txcaretakerOverview', 'access' => 'user,group', diff --git a/mod_nav/index.php b/mod_nav/index.php index 7c3e1a5c..a332de4d 100644 --- a/mod_nav/index.php +++ b/mod_nav/index.php @@ -97,30 +97,30 @@ public function main() $confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['caretaker']); $storagePid = (int)$confArray['storagePid']; - $this->pageRenderer->addJsInlineCode('Caretaker_Nodetree', - ' - Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); - Ext.ns("tx.caretaker"); - Ext.onReady(function() { - tx.caretaker.view = new Ext.Viewport({ - layout: "fit", - items: { - id: "cartaker-tree", - xtype: "caretaker-nodetree", - autoScroll: true, - dataUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::treeloader\'], - getModuleUrlUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::getModuleUrl\'], - storagePid: ' . $storagePid . ', - addUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new" - } - }); - - tx_caretaker_updateTreeById = function( id ){ - tx_caretaker_tree = Ext.getCmp("cartaker-tree"); - tx_caretaker_tree.reloadTreePartial( id ); - } - }); - '); + $this->pageRenderer->addJsInlineCode( + 'Caretaker_Nodetree', + 'Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); + Ext.ns("tx.caretaker"); + Ext.onReady(function() { + tx.caretaker.view = new Ext.Viewport({ + layout: "fit", + items: { + id: "cartaker-tree", + xtype: "caretaker-nodetree", + autoScroll: true, + dataUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::treeloader\'], + getModuleUrlUrl: TYPO3.settings.ajaxUrls[\'tx_caretaker::getModuleUrl\'], + storagePid: ' . $storagePid . ', + addUrl: "' . $PATH_TYPO3 . 'alt_doc.php?edit[###NODE_TYPE###][' . $storagePid . ']=new" + } + }); + + tx_caretaker_updateTreeById = function( id ){ + tx_caretaker_tree = Ext.getCmp("cartaker-tree"); + tx_caretaker_tree.reloadTreePartial( id ); + } + });' + ); $this->content .= $this->doc->startPage($LANG->getLL('title')); $this->doc->form = ''; diff --git a/scheduler/class.tx_caretaker_testrunnertask.php b/scheduler/class.tx_caretaker_testrunnertask.php index 20517568..404375ec 100644 --- a/scheduler/class.tx_caretaker_testrunnertask.php +++ b/scheduler/class.tx_caretaker_testrunnertask.php @@ -23,7 +23,9 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use TYPO3\CMS\Core\Locking\LockFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Scheduler\Task\AbstractTask; /** * This is a file of the caretaker project. @@ -45,7 +47,7 @@ * @author Tobias Liebig * */ -class tx_caretaker_TestrunnerTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask +class tx_caretaker_TestrunnerTask extends AbstractTask { /** * @var string @@ -73,27 +75,25 @@ public function getNodeId() */ public function execute() { - $node_repository = tx_caretaker_NodeRepository::getInstance(); - $node = $node_repository->id2node($this->node_id); + $node = tx_caretaker_NodeRepository::getInstance()->id2node($this->node_id); if (!$node) { return false; } if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode'] != 'disable') { - if (class_exists('\\TYPO3\\CMS\\Core\\Locking\\LockFactory')) { - $lockObj = GeneralUtility::makeInstance('TYPO3\CMS\Core\Locking\LockFactory')->createLocker('tx_caretaker_update_' . $node->getCaretakerNodeId()); - } else { - $lockObj = GeneralUtility::makeInstance('TYPO3\CMS\Core\Locking\Locker', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); - } - // no output during scheduler runs - tx_caretaker_ServiceHelper::unregisterCaretakerNotificationService('CliNotificationService'); + try { + $lockingStrategy = GeneralUtility::makeInstance(LockFactory::class) + ->createLocker('tx_caretaker_update_' . $node->getCaretakerNodeId()); + + // no output during scheduler runs + tx_caretaker_ServiceHelper::unregisterCaretakerNotificationService('CliNotificationService'); - if ($lockObj->acquire()) { + $lockingStrategy->acquire(); $node->updateTestResult(); - $lockObj->release(); - } else { - return true; + $lockingStrategy->release(); + } catch (Exception $e) { + return false; } } else { $node->updateTestResult(); @@ -109,7 +109,3 @@ public function execute() return true; } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/caretaker/scheduler/class.tx_caretaker_testrunnertask.php']) { - include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/caretaker/scheduler/class.tx_caretaker_testrunnertask.php']); -}