TYPO3 API  SVNRelease
scheduler_cli_dispatch.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2008 Markus Friedrich (markus.friedrich@dkd.de>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 /**
00026  * Starts all due tasks, used by the command line interface
00027  * This script must be included by the "CLI module dispatcher"
00028  *
00029  * @author      Markus Friedrich <markus.friedrich@dkd.de>
00030  * @package     TYPO3
00031  * @subpackage  tx_scheduler
00032  *
00033  * $Id: scheduler_cli_dispatch.php 8084 2010-07-04 07:55:53Z francois $
00034  */
00035 if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) && basename(PATH_thisScript) == 'cli_dispatch.phpsh') {
00036     $hasTask = true;
00037         // Create an instance of the scheduler object
00038         /**
00039          * @var tx_scheduler
00040          */
00041     $scheduler = t3lib_div::makeInstance('tx_scheduler');
00042         // Loop as long as there are tasks
00043     do {
00044             // Try getting the next task and execute it
00045             // If there are no more tasks to execute, an exception is thrown by tx_scheduler::fetchTask()
00046         try {
00047                 /**
00048                  * @var tx_scheduler_Task
00049                  */
00050             $task = $scheduler->fetchTask();
00051             $hasTask = true;
00052             try {
00053                 $scheduler->executeTask($task);
00054             }
00055             catch (Exception $e) {
00056                     // We ignore any exception that may have been thrown during execution,
00057                     // as this is a background process.
00058                     // The exception message has been recorded to the database anyway
00059                 continue;
00060             }
00061         }
00062             // There are no more tasks, quit the run
00063         catch (OutOfBoundsException $e) {
00064             $hasTask = false;
00065         }
00066             // A task could not be unserialized properly, skip to next task
00067         catch (UnexpectedValueException $e) {
00068             continue;
00069         }
00070     } while ($hasTask);
00071         // Record the run in the system registry
00072     $scheduler->recordLastRun();
00073 } else {
00074     die('This script must be included by the "CLI module dispatcher"');
00075 }
00076 
00077 ?>