Skip to content

Commit a124897

Browse files
Fix Warnings and Errors for Deprecated Things in PHP8 (#1151)
1 parent e2a7cc8 commit a124897

11 files changed

+36
-25
lines changed

src/Classes/MyRadio/MyRadioFormField.php

+7
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ class MyRadioFormField
331331
*/
332332
private $redacted = false;
333333

334+
/**
335+
* Placeholder for the field
336+
*
337+
* @var mixed
338+
*/
339+
private $placeholder = null;
340+
334341
/**
335342
* Settings that cannot be altered by the $options parameter.
336343
*

src/Classes/MyRadio/MyRadioMenu.php

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ private function getFullMenu()
9393
*/
9494
private function getFullSubMenu($module)
9595
{
96+
if ($module == "MyRadio") {
97+
// bypass for the MyRadio module, which doesn't have header menus
98+
return [];
99+
}
100+
96101
$menu = json_decode(@file_get_contents('Menus/'.$module.'.json', FILE_USE_INCLUDE_PATH), true);
97102

98103
if (is_null($menu)) {

src/Classes/MyRadioTwig.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use MyRadio\MyRadioException;
1111
use MyRadio\MyRadioError;
1212
use Twig\TwigFunction;
13-
use Twig_Loader_Filesystem;
14-
use Twig_Environment;
13+
use Twig\Loader\FilesystemLoader;
14+
use Twig\Environment;
1515
use Twig_Extension_Debug;
1616

1717
/**
@@ -32,9 +32,9 @@ class MyRadioTwig implements \MyRadio\Iface\TemplateEngine
3232
*/
3333
public function __construct()
3434
{
35-
$twig_loader = new Twig_Loader_Filesystem(__DIR__.'/../Templates/');
35+
$twig_loader = new FilesystemLoader(__DIR__.'/../Templates/');
3636
$this->contextVariables['notices'] = [];
37-
$this->twig = new Twig_Environment($twig_loader, ['auto_reload' => true]);
37+
$this->twig = new Environment($twig_loader, ['auto_reload' => true]);
3838
if (Config::$template_debug) {
3939
$this->twig->addExtension(new Twig_Extension_Debug());
4040
$this->twig->enableDebug();
@@ -175,7 +175,7 @@ public function setTemplate($template)
175175
//Validate template
176176
try {
177177
$this->twig->parse($this->twig->tokenize(
178-
new \Twig_Source(file_get_contents(__DIR__.'/../Templates/'.$template), $template)
178+
new \Twig\Source(file_get_contents(__DIR__.'/../Templates/'.$template), $template)
179179
));
180180

181181
// the $template is valid

src/Classes/ServiceAPI/MyRadio_ChartRelease.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public function toDataSource($mixins = [])
448448
{
449449
return [
450450
'type' => $this->getChartType()->getDescription(),
451-
'date' => strftime('%c', $this->getReleaseTime()),
451+
'date' => date('d/m/Y', $this->getReleaseTime()),
452452
'editlink' => [
453453
'display' => 'icon',
454454
'value' => 'pencil',

src/Classes/ServiceAPI/MyRadio_Event.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ public function getEditForm()
364364
[
365365
'title' => $this->getTitle(),
366366
'description_html' => $this->getDescriptionHtml(),
367-
'start_time' => strftime('%d/%m/%Y %H:%M', $this->getStartTime()),
368-
'end_time' => strftime('%d/%m/%Y %H:%M', $this->getEndTime())
367+
'start_time' => date('d/m/Y H:i', $this->getStartTime()),
368+
'end_time' => date('d/m/Y H:i', $this->getEndTime())
369369
]
370370
);
371371
}

src/Classes/ServiceAPI/MyRadio_Season.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function __construct($season_id)
109109
//Deal with the easy bits
110110
$this->owner = MyRadio_User::getInstance($result['memberid']);
111111
$this->show_id = (int) $result['show_id'];
112-
$this->submitted = strtotime($result['submitted']);
112+
$this->submitted = $result['submitted'] !== null ? strtotime($result['submitted']) : null;
113113
$this->term_id = (int) $result['termid'];
114114
$this->season_num = (int) $result['season_num'];
115115
$this->subtype_id = (int) $result['subtype_id'];

src/Classes/ServiceAPI/MyRadio_Show.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,8 @@ protected function __construct($result)
146146
}
147147

148148
//Deal with the Credits arrays
149-
$credit_types = json_decode($result['credit_types']);
150-
$credits = json_decode($result['credits']);
151-
if ($credit_types === null) {
152-
$credit_types = [];
153-
}
154-
if ($credits === null) {
155-
$credits = [];
156-
}
149+
$credit_types = $result['credit_types'] !== null ? json_decode($result['credit_types']) : [];
150+
$credits = $result['credits'] !== null ? json_decode($result['credits']) : [];
157151

158152
for ($i = 0; $i < sizeof($credits); ++$i) {
159153
if (empty($credits[$i])) {
@@ -190,8 +184,8 @@ protected function __construct($result)
190184
* @todo Support general photo attachment?
191185
*/
192186
$this->photo_url = Config::$default_person_uri;
193-
$image_metadata = json_decode($result['image_metadata_values']);
194187
if ($result['image_metadata_values'] !== null) {
188+
$image_metadata = json_decode($result['image_metadata_values']);
195189
$this->photo_url = Config::$public_media_uri.'/'.$image_metadata[0];
196190
}
197191

src/Classes/ServiceAPI/MyRadio_Timeslot.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ function ($x) {
12951295
'user' => MyRadio_User::getInstance($x['memberid']),
12961296
'signedby' => $x['signerid'] ? MyRadio_User::getInstance($x['signerid']) : null,
12971297
'location' => $x['location_name'],
1298-
'time' => strtotime($x['sign_time'])
1298+
'time' => $x['sign_time'] !== null ? strtotime($x['sign_time']) : null
12991299
];
13001300
},
13011301
$result

src/Classes/ServiceAPI/MyRadio_User.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ public function getPermissionsInfo()
574574
*/
575575
public function getEmail()
576576
{
577+
if (empty($this->email)) {
578+
return $this->getEduroam().'@'.Config::$eduroam_domain;
579+
}
580+
577581
$domain = $domain = substr(strrchr($this->email, '@'), 1);
578582
if (in_array($domain, Config::$local_email_domains)) {
579583
//The user has set an alias or their local mailbox here.
@@ -590,8 +594,6 @@ public function getEmail()
590594
return $eduroam.'@'.Config::$eduroam_domain;
591595
}
592596
}
593-
} elseif (empty($this->email)) {
594-
return $this->getEduroam().'@'.Config::$eduroam_domain;
595597
} else {
596598
return $this->email;
597599
}
@@ -620,6 +622,9 @@ public function getPublicEmail()
620622
*/
621623
public function getEduroam()
622624
{
625+
if ($this->eduroam == null) {
626+
return "";
627+
}
623628
return str_replace('@'.Config::$eduroam_domain, '', $this->eduroam);
624629
}
625630

src/Classes/ServiceAPI/MyRadio_UserOfficership.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public function toDataSource($mixins = [])
8585
// Ensure we don't get infinite recursion
8686
'member' => $this->getUser()->toDataSource(),
8787
'officer' => $this->getOfficer()->toDataSource(),
88-
'from_date' => strftime("%Y-%m-%d", $this->from_date),
89-
'till_date' => $this->till_date === null ? null : strftime("%Y-%m-%d", $this->till_date),
88+
'from_date' => date("Y-m-d", $this->from_date),
89+
'till_date' => $this->till_date === null ? null : date("Y-m-d", $this->till_date),
9090
// Compatibility with old MyRadio_User::getOfficerships
9191
'officer_name' => $this->getOfficer()->getName(),
9292
];

src/Controllers/Events/duplicateEvent.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
unset($vals['host']);
1717
unset($vals['start']);
1818
unset($vals['end']);
19-
$vals['start_time'] = strftime('%d/%m/%Y %H:%M', $event->getStartTime());
20-
$vals['end_time'] = strftime('%d/%m/%Y %H:%M', $event->getEndTime());
19+
$vals['start_time'] = date('d/m/Y H:i', $event->getStartTime());
20+
$vals['end_time'] = date('d/m/Y H:i', $event->getEndTime());
2121

2222
MyRadio_Event::getForm()
2323
->setValues($vals)

0 commit comments

Comments
 (0)