Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug related to missing DTSTART property #342

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 36 additions & 45 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
{
"name": "johngrogg/ics-parser",
"description": "ICS Parser",
"homepage": "https://github.com/u01jmg3/ics-parser",
"keywords": [
"ical",
"ical-parser",
"icalendar",
"ics",
"ics-parser",
"ifb"
],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Jonathan Goode",
"role": "Developer/Owner"
},
{
"name": "John Grogg",
"email": "[email protected]",
"role": "Developer/Prior Owner"
}
],
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/u01jmg3"
}
],
"require": {
"php": ">=5.6.40",
"ext-mbstring": "*"
"name": "abdulsametsahin/ics-parser",
"description": "ICS Parser",
"homepage": "https://github.com/u01jmg3/ics-parser",
"keywords": ["ical", "ical-parser", "icalendar", "ics", "ics-parser", "ifb"],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Jonathan Goode",
"role": "Developer/Owner"
},
"require-dev": {
"phpunit/phpunit": "^5|^9|^10"
},
"autoload": {
"psr-0": {
"ICal": "src/"
}
},
"scripts": {
"test": [
"phpunit --colors=always"
]
{
"name": "John Grogg",
"email": "[email protected]",
"role": "Developer/Prior Owner"
}
],
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/u01jmg3"
}
],
"require": {
"php": ">=5.6.40",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^5|^9|^10"
},
"autoload": {
"psr-0": {
"ICal": "src/"
}
},
"scripts": {
"test": ["phpunit --colors=always"]
}
}
26 changes: 26 additions & 0 deletions src/ICal/ICal.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ class ICal
*/
protected $httpProtocolVersion;

/**
* Toggles whether to ignore incomplete events
*
* @var boolean
*/
protected $ignoreIncompleteEvents = false;

/**
* Define which variables can be configured
*
Expand All @@ -213,6 +220,7 @@ class ICal
'filterDaysBefore',
'httpUserAgent',
'skipRecurrence',
'ignoreIncompleteEvents'
);

/**
Expand Down Expand Up @@ -1283,6 +1291,11 @@ protected function processEvents()

if ($events !== array()) {
foreach ($events as $key => $anEvent) {
if ($this->ignoreIncompleteEvents && !$this->hasAllRequiredFields($anEvent)) {
unset($events[$key]);
continue;
}

foreach (array('DTSTART', 'DTEND', 'RECURRENCE-ID') as $type) {
if (isset($anEvent[$type])) {
$date = $anEvent["{$type}_array"][1];
Expand Down Expand Up @@ -2728,4 +2741,17 @@ public function timeZoneStringToDateTimeZone($timeZoneString)

return new \DateTimeZone($this->getDefaultTimeZone());
}

public function hasAllRequiredFields($event)
{
$requiredFields = ['UID', 'DTSTAMP', 'DTSTART'];

foreach ($requiredFields as $field) {
if (!isset($event[$field])) {
return false;
}
}

return true;
}
}