From f64997c0eebbf854345e668850eaa2f982f65967 Mon Sep 17 00:00:00 2001 From: TjorbenWridt Date: Wed, 18 Feb 2015 11:24:26 +0100 Subject: [PATCH] Update class.tx_caretakerselftest_TerUpdateTestService.php The table for the TER repositories has been changed. There is a new function which works with TYPO3 6.x . The condition part was enhanced to call the new function only if TYPO3 version is 6.x . Changed the not set variable $age to $minTimestamp in the 4.5 function. --- ...caretakerselftest_TerUpdateTestService.php | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/services/class.tx_caretakerselftest_TerUpdateTestService.php b/services/class.tx_caretakerselftest_TerUpdateTestService.php index d42ab5d..d0839ba 100644 --- a/services/class.tx_caretakerselftest_TerUpdateTestService.php +++ b/services/class.tx_caretakerselftest_TerUpdateTestService.php @@ -52,8 +52,10 @@ public function runTest() { if ( t3lib_div::int_from_ver( TYPO3_version ) < t3lib_div::int_from_ver( '4.5.0' ) ){ return $this->runTest400(); - } else { + } elseif( t3lib_div::int_from_ver( TYPO3_version ) < t3lib_div::int_from_ver( '6.0.0' ) ) { return $this->runTest450(); + } else { + return $this->runTest600(); } } @@ -91,9 +93,34 @@ private function runTest450(){ } if ( count($errors) > 0 ){ - return tx_caretaker_TestResult::create( tx_caretaker_Constants::state_error, $age, count($errors) . ' extension repositories have to be updated. ' . count($ok) . ' extension repositories are ok. ' , array_merge( $errors, $ok ) ); + return tx_caretaker_TestResult::create( tx_caretaker_Constants::state_error, $minTimstamp, count($errors) . ' extension repositories have to be updated. ' . count($ok) . ' extension repositories are ok. ' , array_merge( $errors, $ok ) ); + } else { + return tx_caretaker_TestResult::create( tx_caretaker_Constants::state_ok, $minTimstamp, count($ok) . ' extension repositories are ok. ', $ok ); + } + + } + + private function runTest600(){ + $config = $this->getConfiguration(); + $minTimstamp = time() - $config['maxAge']; + + $repositories = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows ( '*', 'tx_extensionmanager_domain_model_repository', '1' ); + + $errors = array(); + $ok = array(); + + foreach( $repositories as $repository ){ + if ( $repository['last_update'] < $minTimstamp ){ + $errors[] = new tx_caretaker_ResultMessage( 'ERROR: Extension-repository ' . $repository['title'] . ' was not up to date. Last update was on ' . strftime ( '%x %X' , $repository['last_update'] ) ); + } else { + $ok[] = new tx_caretaker_ResultMessage( 'OK: Extension-repository ' . $repository['title'] . ' is up to date. Last update was on ' . strftime ( '%x %X' , $repository['last_update'] ) ); + } + } + + if ( count($errors) > 0 ){ + return tx_caretaker_TestResult::create( tx_caretaker_Constants::state_error, $minTimstamp, count($errors) . ' extension repositories have to be updated. ' . count($ok) . ' extension repositories are ok. ' , array_merge( $errors, $ok ) ); } else { - return tx_caretaker_TestResult::create( tx_caretaker_Constants::state_ok, $age, count($ok) . ' extension repositories are ok. ', $ok ); + return tx_caretaker_TestResult::create( tx_caretaker_Constants::state_ok, $minTimstamp, count($ok) . ' extension repositories are ok. ', $ok ); } }