public function execute()
 {
     return tx_caretaker_LatestVersionsHelper::updateLatestTypo3VersionRegistry();
 }
コード例 #2
0
 /**
  * @param array $argv
  */
 public function cli_main($argv)
 {
     $task = (string) $this->cli_args['_DEFAULT'][1];
     if (!$task) {
         $this->cli_validateArgs();
         $this->cli_help();
         exit;
     }
     if ($task == 'update' || $task == 'get' || $task == 'ack' || $task == 'due') {
         $force = (bool) $this->readArgument('--force', '-f');
         $return_status = (bool) $this->readArgument('-r');
         $options = array('forceUpdate' => $force);
         $options = array_merge($options, $this->parseOptions($this->readArgument('--options', '-o')));
         $node = FALSE;
         $node_repository = tx_caretaker_NodeRepository::getInstance();
         $nodeId = $this->readArgument('--node', '-N');
         if ((bool) $this->readArgument('--root', '-R')) {
             $node = $node_repository->getRootNode();
         } else {
             if ($nodeId) {
                 $node = $node_repository->id2node($nodeId);
             }
         }
         if ($node) {
             $this->cli_echo('node ' . $node->getCaretakerNodeId() . chr(10));
             $result = FALSE;
             if ($task == 'update' || $task == 'ack' || $task == 'due') {
                 try {
                     $lockObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
                     $lockIsAquired = $lockObj->acquire();
                 } catch (Exception $e) {
                     $this->cli_echo('lock ' . 'tx_caretaker_update_' . $node->getCaretakerNodeId() . ' could not be aquired!' . chr(10) . $e->getMessage());
                     exit;
                 }
                 if ($lockIsAquired) {
                     if ($task == 'update') {
                         $result = $node->updateTestResult($options);
                     } else {
                         if ($task == 'ack' && is_a($node, 'tx_caretaker_TestNode')) {
                             $result = $node->setModeAck();
                         } else {
                             if ($task == 'due' && is_a($node, 'tx_caretaker_TestNode')) {
                                 $result = $node->setModeDue();
                             }
                         }
                     }
                     $lockObj->release();
                 } else {
                     $result = false;
                     $this->cli_echo('node ' . $node->getCaretakerNodeId() . ' is locked because of other running update processes!' . chr(10));
                     exit;
                 }
             }
             if ($task == 'get') {
                 $result = $node->getTestResult();
                 $this->cli_echo($node->getTitle() . ' [' . $node->getCaretakerNodeId() . ']' . chr(10));
                 $this->cli_echo($result->getLocallizedStateInfo() . ' [' . $node->getCaretakerNodeId() . ']' . chr(10));
             }
             // send aggregated notifications
             $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices();
             /** @var tx_caretaker_NotificationBaseExitPoint $notificationService */
             foreach ($notificationServices as $notificationService) {
                 $notificationService->sendNotifications();
             }
             if ($return_status) {
                 exit((int) $result->getState());
             } else {
                 exit;
             }
         } else {
             $this->cli_echo('Node not found or inactive' . chr(10));
             exit;
         }
     } elseif ($task == 'update-typo3-latest-version-list') {
         $result = tx_caretaker_LatestVersionsHelper::updateLatestTypo3VersionRegistry();
         $this->cli_echo('TYPO3 latest version list update result: ' . $result . chr(10));
         $versions = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry')->get('tx_caretaker', 'TYPO3versions');
         foreach ($versions as $key => $version) {
             $this->cli_echo($key . ' => ' . $version . chr(10));
         }
     }
     if ($task == 'help') {
         $this->cli_validateArgs();
         $this->cli_help();
         exit;
     }
 }
 public function execute()
 {
     $success = tx_caretaker_LatestVersionsHelper::updateLatestTypo3VersionRegistry();
     return $success;
 }