Skip to content

Commit

Permalink
Fixed PHP 5.6 compatibility issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Jun 19, 2024
1 parent d865861 commit 9b56b83
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.4.1] - 2024-06-19
### Updated
- Fixed compatibility with PHP 5.6.

## [1.4.0] - 2024-04-26
### Added
- GitHub actions CI workflow.
Expand Down
8 changes: 4 additions & 4 deletions classes/local_contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function __construct() {
$this->fromemail = required_param('email', PARAM_TEXT);
}
}
$this->fromname = trim($this->fromname ?? '');
$this->fromemail = trim($this->fromemail ?? '');
$this->fromname = isset($this->fromname) ? trim($this->fromname) : '';
$this->fromemail = isset($this->fromemail) ? trim($this->fromemail) : '';

$this->isspambot = false;
$this->errmsg = '';
Expand Down Expand Up @@ -247,7 +247,7 @@ public function __construct() {
*/
private function makeemailuser($email, $name = '', $id = -99) {
$emailuser = new stdClass();
$emailuser->email = trim(filter_var($email, FILTER_SANITIZE_EMAIL) ?? '');
$emailuser->email = trim(filter_var($email, FILTER_SANITIZE_EMAIL) ? filter_var($email, FILTER_SANITIZE_EMAIL) : '');
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailuser->email = '';
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public function sendmessage($email, $name, $sendconfirmationemail = false) {
* @return boolean true if string is not empty, otherwise false.
*/
function filterempty($string) {
$string = trim($string ?? '');
$string = isset($string) ? trim($string) : '';
return ($string !== null && $string !== false && $string !== '');
}

Expand Down
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@

// The default recipient is the Moodle site's support contact. This will
// be used if no recipient was specified or if the recipient is unknown.
$name = trim($CFG->supportname ?? '');
$email = trim($CFG->supportemail ?? '');
$name = isset($CFG->supportname) ? trim($CFG->supportname) : '';
$email = isset($CFG->supportemail) ? trim($CFG->supportemail) : '';

// Handle recipient alias.
// If the form includes a recipient's alias, search the plugin's recipient list settings for a name and email address.
$recipient = trim(optional_param('recipient', '', PARAM_TEXT));
if (!empty($recipient)) {
$lines = explode("\n", get_config('local_contact', 'recipient_list'));
foreach ($lines as $linenumbe => $line) {
$line = trim($line ?? '');
$line = isset($line) ? trim($line) : '';
if (empty($line)) { // Blank line.
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024042600; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2024061900; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2015111600; // Requires Moodle version 3.0.
$plugin->component = 'local_contact'; // To check on upgrade, that module sits in correct place.
$plugin->release = '1.4.0';
$plugin->release = '1.4.1';
$plugin->maturity = MATURITY_STABLE;
$plugin->cron = 0;

0 comments on commit 9b56b83

Please sign in to comment.