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

Fix Warnings and Errors for Deprecated Things in PHP8 #1151

Merged
merged 1 commit into from
Aug 26, 2024
Merged
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
7 changes: 7 additions & 0 deletions src/Classes/MyRadio/MyRadioFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ class MyRadioFormField
*/
private $redacted = false;

/**
* Placeholder for the field
*
* @var mixed
*/
private $placeholder = null;

/**
* Settings that cannot be altered by the $options parameter.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Classes/MyRadio/MyRadioMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ private function getFullMenu()
*/
private function getFullSubMenu($module)
{
if ($module == "MyRadio") {
// bypass for the MyRadio module, which doesn't have header menus
return [];
}

$menu = json_decode(@file_get_contents('Menus/'.$module.'.json', FILE_USE_INCLUDE_PATH), true);

if (is_null($menu)) {
Expand Down
10 changes: 5 additions & 5 deletions src/Classes/MyRadioTwig.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use MyRadio\MyRadioException;
use MyRadio\MyRadioError;
use Twig\TwigFunction;
use Twig_Loader_Filesystem;
use Twig_Environment;
use Twig\Loader\FilesystemLoader;
use Twig\Environment;
use Twig_Extension_Debug;

/**
Expand All @@ -32,9 +32,9 @@ class MyRadioTwig implements \MyRadio\Iface\TemplateEngine
*/
public function __construct()
{
$twig_loader = new Twig_Loader_Filesystem(__DIR__.'/../Templates/');
$twig_loader = new FilesystemLoader(__DIR__.'/../Templates/');
$this->contextVariables['notices'] = [];
$this->twig = new Twig_Environment($twig_loader, ['auto_reload' => true]);
$this->twig = new Environment($twig_loader, ['auto_reload' => true]);
if (Config::$template_debug) {
$this->twig->addExtension(new Twig_Extension_Debug());
$this->twig->enableDebug();
Expand Down Expand Up @@ -175,7 +175,7 @@ public function setTemplate($template)
//Validate template
try {
$this->twig->parse($this->twig->tokenize(
new \Twig_Source(file_get_contents(__DIR__.'/../Templates/'.$template), $template)
new \Twig\Source(file_get_contents(__DIR__.'/../Templates/'.$template), $template)
));

// the $template is valid
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ServiceAPI/MyRadio_ChartRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public function toDataSource($mixins = [])
{
return [
'type' => $this->getChartType()->getDescription(),
'date' => strftime('%c', $this->getReleaseTime()),
'date' => date('d/m/Y', $this->getReleaseTime()),
'editlink' => [
'display' => 'icon',
'value' => 'pencil',
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/ServiceAPI/MyRadio_Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ public function getEditForm()
[
'title' => $this->getTitle(),
'description_html' => $this->getDescriptionHtml(),
'start_time' => strftime('%d/%m/%Y %H:%M', $this->getStartTime()),
'end_time' => strftime('%d/%m/%Y %H:%M', $this->getEndTime())
'start_time' => date('d/m/Y H:i', $this->getStartTime()),
'end_time' => date('d/m/Y H:i', $this->getEndTime())
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ServiceAPI/MyRadio_Season.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function __construct($season_id)
//Deal with the easy bits
$this->owner = MyRadio_User::getInstance($result['memberid']);
$this->show_id = (int) $result['show_id'];
$this->submitted = strtotime($result['submitted']);
$this->submitted = $result['submitted'] !== null ? strtotime($result['submitted']) : null;
$this->term_id = (int) $result['termid'];
$this->season_num = (int) $result['season_num'];
$this->subtype_id = (int) $result['subtype_id'];
Expand Down
12 changes: 3 additions & 9 deletions src/Classes/ServiceAPI/MyRadio_Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,8 @@ protected function __construct($result)
}

//Deal with the Credits arrays
$credit_types = json_decode($result['credit_types']);
$credits = json_decode($result['credits']);
if ($credit_types === null) {
$credit_types = [];
}
if ($credits === null) {
$credits = [];
}
$credit_types = $result['credit_types'] !== null ? json_decode($result['credit_types']) : [];
$credits = $result['credits'] !== null ? json_decode($result['credits']) : [];

for ($i = 0; $i < sizeof($credits); ++$i) {
if (empty($credits[$i])) {
Expand Down Expand Up @@ -190,8 +184,8 @@ protected function __construct($result)
* @todo Support general photo attachment?
*/
$this->photo_url = Config::$default_person_uri;
$image_metadata = json_decode($result['image_metadata_values']);
if ($result['image_metadata_values'] !== null) {
$image_metadata = json_decode($result['image_metadata_values']);
$this->photo_url = Config::$public_media_uri.'/'.$image_metadata[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ServiceAPI/MyRadio_Timeslot.php
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ function ($x) {
'user' => MyRadio_User::getInstance($x['memberid']),
'signedby' => $x['signerid'] ? MyRadio_User::getInstance($x['signerid']) : null,
'location' => $x['location_name'],
'time' => strtotime($x['sign_time'])
'time' => $x['sign_time'] !== null ? strtotime($x['sign_time']) : null
];
},
$result
Expand Down
9 changes: 7 additions & 2 deletions src/Classes/ServiceAPI/MyRadio_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ public function getPermissionsInfo()
*/
public function getEmail()
{
if (empty($this->email)) {
return $this->getEduroam().'@'.Config::$eduroam_domain;
}

$domain = $domain = substr(strrchr($this->email, '@'), 1);
if (in_array($domain, Config::$local_email_domains)) {
//The user has set an alias or their local mailbox here.
Expand All @@ -566,8 +570,6 @@ public function getEmail()
return $eduroam.'@'.Config::$eduroam_domain;
}
}
} elseif (empty($this->email)) {
return $this->getEduroam().'@'.Config::$eduroam_domain;
} else {
return $this->email;
}
Expand Down Expand Up @@ -596,6 +598,9 @@ public function getPublicEmail()
*/
public function getEduroam()
{
if ($this->eduroam == null) {
return "";
}
return str_replace('@'.Config::$eduroam_domain, '', $this->eduroam);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Classes/ServiceAPI/MyRadio_UserOfficership.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public function toDataSource($mixins = [])
// Ensure we don't get infinite recursion
'member' => $this->getUser()->toDataSource(),
'officer' => $this->getOfficer()->toDataSource(),
'from_date' => strftime("%Y-%m-%d", $this->from_date),
'till_date' => $this->till_date === null ? null : strftime("%Y-%m-%d", $this->till_date),
'from_date' => date("Y-m-d", $this->from_date),
'till_date' => $this->till_date === null ? null : date("Y-m-d", $this->till_date),
// Compatibility with old MyRadio_User::getOfficerships
'officer_name' => $this->getOfficer()->getName(),
];
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/Events/duplicateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
unset($vals['host']);
unset($vals['start']);
unset($vals['end']);
$vals['start_time'] = strftime('%d/%m/%Y %H:%M', $event->getStartTime());
$vals['end_time'] = strftime('%d/%m/%Y %H:%M', $event->getEndTime());
$vals['start_time'] = date('d/m/Y H:i', $event->getStartTime());
$vals['end_time'] = date('d/m/Y H:i', $event->getEndTime());

MyRadio_Event::getForm()
->setValues($vals)
Expand Down