From 042172ff8ef9ca2726941012c2a4aae0e49b307c Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 9 Sep 2011 12:06:23 +0200 Subject: [PATCH] Updates some documentation + CronjobUtil "fixes" Additionally in `wcf\util\CronjobUtil::calculateNextExec()` the `$values` variable is initialized, the arrays with the day and month abbreviations are created before the foreach loop and the array name in the dow case is corrected. --- .../files/lib/util/CronjobUtil.class.php | 29 ++++++++----------- .../install/files/lib/util/DateUtil.class.php | 12 ++++---- wcfsetup/install/files/lib/util/XML.class.php | 10 ++----- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/wcfsetup/install/files/lib/util/CronjobUtil.class.php b/wcfsetup/install/files/lib/util/CronjobUtil.class.php index a1e5354470..bebedd7ca0 100644 --- a/wcfsetup/install/files/lib/util/CronjobUtil.class.php +++ b/wcfsetup/install/files/lib/util/CronjobUtil.class.php @@ -15,38 +15,33 @@ namespace wcf\util; */ abstract class CronjobUtil { /** - * Set to true if day of month is '*' - * + * indicates if day of month is restricted (not '*') * @var boolean */ protected static $domRestricted = false; /** - * Set to true if day of week is '*' - * + * indicates if day of week is restricted (not '*') * @var boolean */ protected static $dowRestricted = false; /** - * Result date - * + * result date * @var array */ protected static $result = array(); /** - * Time based used as reference for finding the next time of execution - * + * time base used as reference for finding the next execution time * @var integer */ protected static $timeBase = 0; /** - * Valid ranges for each known field. Note that the range for - * 'day of month' is missing, since it varies on each month. - * - * @var array + * valid ranges for each known field (range for 'day of month' is missing + * since it varies from month to month) + * @var array */ public static $ranges = array( 'minute' => array(0, 59), @@ -89,7 +84,11 @@ abstract class CronjobUtil { self::$domRestricted = ($dom != '*') ? true : false; self::$dowRestricted = ($dow != '*') ? true : false; + $dayNames = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); + $monthNames = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'); + // calculate values based upon each expression + $values = array(); foreach ($fields as $fieldName => $fieldValue) { $fieldValue = StringUtil::toLowerCase($fieldValue); @@ -100,10 +99,8 @@ abstract class CronjobUtil { switch ($fieldName) { case 'dow': - $dayNames = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); - if (strlen($fieldValue) == 3 && in_array($fieldName, $dayNames)) { - $fieldValue = $monthNames[$fieldValue]; + $fieldValue = $dayNames[$fieldValue]; } // When specifying day of week, both day 0 and day 7 // will be considered Sunday. -- crontab(5) @@ -113,8 +110,6 @@ abstract class CronjobUtil { break; case 'month': - $monthNames = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'); - if (strlen($fieldValue) == 3 && in_array($fieldValue, $monthNames)) { $fieldValue = $monthNames[$fieldValue] + 1; } diff --git a/wcfsetup/install/files/lib/util/DateUtil.class.php b/wcfsetup/install/files/lib/util/DateUtil.class.php index 43dcebb7d9..59219512c7 100644 --- a/wcfsetup/install/files/lib/util/DateUtil.class.php +++ b/wcfsetup/install/files/lib/util/DateUtil.class.php @@ -133,10 +133,10 @@ class DateUtil { /** * Returns a formatted date. * - * @param DateTime $time - * @param string $format - * @param Language $language - * @param User $user + * @param \DateTime $time + * @param string $format + * @param wcf\data\language\Language $language + * @param wcf\data\user\User $user */ public static function format(\DateTime $time = null, $format = null, Language $language = null, User $user = null) { // get default values @@ -162,7 +162,7 @@ class DateUtil { * * @param string $date * @param string $format - * @param Language $language + * @param wcf\data\language\Language $language */ public static function localizeDate($date, $format, Language $language) { if ($language->languageCode != 'en') { @@ -236,7 +236,7 @@ class DateUtil { * Creates a DateTime object with the given unix timestamp. * * @param integer $timestamp - * @return DateTime + * @return \DateTime */ public static function getDateTimeByTimestamp($timestamp) { return new \DateTime('@'.$timestamp); diff --git a/wcfsetup/install/files/lib/util/XML.class.php b/wcfsetup/install/files/lib/util/XML.class.php index a620118338..fb295b5b4c 100644 --- a/wcfsetup/install/files/lib/util/XML.class.php +++ b/wcfsetup/install/files/lib/util/XML.class.php @@ -15,29 +15,25 @@ use wcf\system\exception\SystemException; class XML { /** * DOMDocument object - * - * @var DOMDocument + * @var \DOMDocument */ protected $document = null; /** * document path - * * @var string */ protected $path = ''; /** * schema file path - * * @var string */ protected $schema = ''; /** * DOMXPath object - * - * @var DOMXPath + * @var \DOMXPath */ protected $xpath = null; @@ -134,7 +130,7 @@ class XML { * Returns a DOMXPath object bound to current DOMDocument object. Default * namespace will be bound to prefix 'ns'. * - * @return DOMXPath + * @return \DOMXPath */ public function xpath() { if ($this->xpath === null) { -- 2.20.1