diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7451fab..13aad19 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## V1.9.1 08/03/2023
+### Fixed
+* Improve PHP 8.x compatability
+
## V1.9 – 04/11/2021
### Added
• Ability to add ogimage and HEAD content
diff --git a/classes/custompage.php b/classes/custompage.php
index 516084b..8fc1c41 100644
--- a/classes/custompage.php
+++ b/classes/custompage.php
@@ -118,15 +118,17 @@ public static function load($id, $editor = false) {
require_once(dirname(__FILE__) . '/../lib.php');
$data = new \stdClass();
- if (intval($id) > 0) {
- $data = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE id=? LIMIT 1", array(intval($id)));
+ if ((int)$id > 0) {
+ $data = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE id=?", [(int)$id], IGNORE_MULTIPLE);
} else {
// Check url for page name.
$main = explode('?', trim($_SERVER['REQUEST_URI']));
$parts = explode("/", trim($main[0]));
$url = '%' . end($parts) . '%';
- $page = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE menuname LIKE ? limit 1", array(trim($url)));
+ $like_menu_name = $DB->sql_like('menuname', '?');
+
+ $page = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE $like_menu_name", [trim($url)], IGNORE_MULTIPLE);
if ($page) {
$data = $page;
diff --git a/forms/edit.php b/forms/edit.php
index 80f94f4..8c4ea49 100644
--- a/forms/edit.php
+++ b/forms/edit.php
@@ -233,11 +233,10 @@ public function validation($data, $files) {
*/
private function build_html_form() {
global $DB;
- $usertable = $DB->get_record_sql("select * FROM {user} LIMIT 1");
+ $usertable = $DB->get_record_sql("select * FROM {user}", null, IGNORE_MULTIPLE);
$records = json_decode($this->_pagedata);
- // PHP 7.2 now gives an error if the item cannot be counted - pre 7.2 it returned 0.
- $limit = intval(@count($records));
+ $limit = (is_countable($records)) ? count($records) : 0;
$i = 0;
$html = '
' .
diff --git a/lib.php b/lib.php
index 46aca6a..c6912fa 100644
--- a/lib.php
+++ b/lib.php
@@ -84,7 +84,7 @@ function local_pages_build_menu(navigation_node $nav, $parent, global_navigation
$records = $DB->get_records_sql("SELECT * FROM {local_pages} WHERE deleted=0 AND onmenu=1 " .
"AND pagetype='page' AND pageparent=? AND pagedate <=? " .
"ORDER BY pageorder", array($parent, $today));
- local_pages_process_records($records, $nav, false, $gnav);
+ local_pages_process_records($records, $nav, $gnav);
}
/**
@@ -99,7 +99,7 @@ function local_pages_build_menu(navigation_node $nav, $parent, global_navigation
* @throws dml_exception
* @throws moodle_exception
*/
-function local_pages_process_records($records, $nav, $parent = false, global_navigation $gnav) {
+function local_pages_process_records($records, $nav, global_navigation $gnav, $parent = false) {
global $CFG;
if ($records) {
foreach ($records as $page) {
@@ -175,7 +175,7 @@ function local_pages_extend_navigation(global_navigation $nav) {
$records = $DB->get_records_sql("SELECT * FROM {local_pages} WHERE deleted=0 AND onmenu=1 " .
"AND pagetype='page' AND pageparent=0 AND pagedate <= ? ORDER BY pageorder", array($today));
- local_pages_process_records($records, $nav, false, $nav);
+ local_pages_process_records($records, $nav, $nav);
}
/**
diff --git a/version.php b/version.php
index 0697d34..de88e53 100644
--- a/version.php
+++ b/version.php
@@ -25,8 +25,8 @@
defined('MOODLE_INTERNAL') || die;
-$plugin->requires = 2020061500; // This plugin requires Moodle VER 3.9.
-$plugin->version = 2021110400; // This plugins version number.
-$plugin->release = 'v1.9'; // This plugins release number.
-$plugin->maturity = MATURITY_STABLE;
-$plugin->component = 'local_pages';
+$plugin->requires = 2021051700; // Moodle 3.11
+$plugin->version = 2023030800;
+$plugin->release = '1.9.1';
+$plugin->maturity = MATURITY_STABLE;
+$plugin->component = 'local_pages';