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

4 php8.1 #1

Open
wants to merge 3 commits into
base: 4
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require": {
"silverstripe/cms": "^4",
"johngrogg/ics-parser": "^2",
"nesbot/carbon": "1.39.1"
"nesbot/carbon": "^2"
},
"support": {
"issues": "https://github.com/unclecheese/silverstripe-event-calendar/issues"
Expand Down
50 changes: 25 additions & 25 deletions src/Helpers/CalendarUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@ class CalendarUtil
public static function format_character_replacements($start, $end)
{
return [
strftime('%a', $start),
strftime('%A', $start),
date('D', $start),
date('l'. $start),
date ('j', $start),
date ('d', $start),
date ('S', $start),
date ('n', $start),
date ('m', $start),
strftime('%b', $start),
strftime('%B', $start),
date('M', $start),
date('F', $start),
date ('y', $start),
date ('Y', $start),
strftime('%a', $end),
strftime('%A', $end),
date('D', $end),
date('l'. $end),
date ('j', $end),
date ('d', $end),
date ('S', $end),
date ('n', $end),
date ('m', $end),
strftime('%b', $end),
strftime('%B', $end),
date('M', $end),
date('F', $end),
date ('y', $end),
date ('Y', $end),
];
Expand Down Expand Up @@ -122,8 +122,8 @@ public static function get_date_string($startDate, $endDate)
$strStartDate = null;
$strEndDate = null;

$start = strtotime($startDate);
$end = strtotime($endDate);
$start = strtotime($startDate ?? '');
$end = strtotime($endDate ?? '');

$startYear = date("Y", $start);
$startMonth = date("m", $start);
Expand Down Expand Up @@ -178,21 +178,21 @@ public static function microformat($date, $time, $offset = null)
/**
* @return array
*/
public static function get_months_map($key = '%b')
public static function get_months_map($key = 'M')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any instances that use this method that you will also need to update

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of the moment, there is none

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

{
return [
'01' => strftime($key, strtotime('2000-01-01')),
'02' => strftime($key, strtotime('2000-02-01')),
'03' => strftime($key, strtotime('2000-03-01')),
'04' => strftime($key, strtotime('2000-04-01')),
'05' => strftime($key, strtotime('2000-05-01')),
'06' => strftime($key, strtotime('2000-06-01')),
'07' => strftime($key, strtotime('2000-07-01')),
'08' => strftime($key, strtotime('2000-08-01')),
'09' => strftime($key, strtotime('2000-09-01')),
'10' => strftime($key, strtotime('2000-10-01')),
'11' => strftime($key, strtotime('2000-11-01')),
'12' => strftime($key, strtotime('2000-12-01'))
'01' => date($key, strtotime('2000-01-01')),
'02' => date($key, strtotime('2000-02-01')),
'03' => date($key, strtotime('2000-03-01')),
'04' => date($key, strtotime('2000-04-01')),
'05' => date($key, strtotime('2000-05-01')),
'06' => date($key, strtotime('2000-06-01')),
'07' => date($key, strtotime('2000-07-01')),
'08' => date($key, strtotime('2000-08-01')),
'09' => date($key, strtotime('2000-09-01')),
'10' => date($key, strtotime('2000-10-01')),
'11' => date($key, strtotime('2000-11-01')),
'12' => date($key, strtotime('2000-12-01'))
];
}

Expand Down Expand Up @@ -240,12 +240,12 @@ public static function date_sort_callback($a, $b)
if ($a->StartDate == $b->StartDate) {
if ($a->StartTime == $b->StartTime) {
return 0;
} elseif (strtotime($a->StartTime) > strtotime($b->StartTime)) {
} elseif (strtotime($a->StartTime ?? '') > strtotime($b->StartTime ?? '')) {
return 1;
}
return -1;
}
elseif (strtotime($a->StartDate) > strtotime($b->StartDate)) {
elseif (strtotime($a->StartDate ?? '') > strtotime($b->StartDate ?? '')) {
return 1;
}
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/RecursionReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(CalendarEvent $event)
if ($datetime = DataList::create($this->datetimeClass)
->filter($relation, $event->ID)->first()
) {
$this->ts = strtotime($datetime->StartDate);
$this->ts = strtotime($datetime->StartDate ?? '');
}

if ($event->CustomRecursionType == CalendarEvent::RECUR_INTERVAL_WEEKLY) {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/RecurringDayOfWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function requireDefaultRecords()

public function getTitle()
{
return strftime("%a", Carbon::now()->next($this->Value)->getTimestamp());
return date("D", Carbon::now()->next($this->Value)->getTimestamp());
}


Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public function getNextRecurringEvents($eventObj, $datetimeObj, $limit = null)
$counter = Carbon::parse($datetimeObj->StartDate);

if ($event = $datetimeObj->Event()->DateTimes()->First()) {
$endDate = strtotime($event->EndDate);
$endDate = strtotime($event->EndDate ?? '');
} else {
$endDate = false;
}
Expand Down Expand Up @@ -527,7 +527,7 @@ protected function addRecurringEvents($startDate, $endDate, $recurringEvents, $a
}
// check the end date
if ($recurringEventDatetime->EndDate) {
$endStamp = strtotime($recurringEventDatetime->EndDate);
$endStamp = strtotime($recurringEventDatetime->EndDate ?? '');
if ($endStamp > 0 && $endStamp < $dateCounter->getTimestamp()) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ public function MonthJumpForm()
$this,
__FUNCTION__,
FieldList::create(
$m = DropdownField::create('Month','', CalendarUtil::get_months_map('%B')),
$m = DropdownField::create('Month','', CalendarUtil::get_months_map('F')),
$y = DropdownField::create('Year','', array_combine($yearRange, $yearRange))
),
FieldList::create(
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/CalendarEventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getCurrentDate()
return $allDates->first();
}
if (strtotime($_REQUEST['date']) > 0) {
$date = date('Y-m-d', strtotime($_REQUEST['date']));
$date = date('Y-m-d', strtotime($_REQUEST['date'] ?? ''));
if ($this->Recursion) {
$datetime = $allDates->first();
if ($datetime) {
Expand Down