From be32856374c230ed54c1e4418d3a8ae5cfc45f10 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 28 Feb 2023 11:34:21 +0100 Subject: [PATCH] MDL-77430 plugininfo: php81 deprecation warnings on missing plugins Whenever some plugin is missing from disk but installed, the plugins page (and the upgrade) shows them as "missing from disk". Still, the code tries to do things with their directory that, now, is null. That was silently defaulting to '' in previous php versions, but php81 emits a deprecated warning. So we have to check for them. --- lib/classes/plugin_manager.php | 2 +- lib/classes/plugininfo/base.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index ea6a3293013..00feacac81c 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1651,7 +1651,7 @@ class core_plugin_manager { } // To be able to remove the plugin folder, its parent must be writable, too. - if (!is_writable(dirname($pluginfo->rootdir))) { + if (!isset($pluginfo->rootdir) || !is_writable(dirname($pluginfo->rootdir))) { return false; } diff --git a/lib/classes/plugininfo/base.php b/lib/classes/plugininfo/base.php index 40e20de4686..4eb39a1b188 100644 --- a/lib/classes/plugininfo/base.php +++ b/lib/classes/plugininfo/base.php @@ -598,6 +598,10 @@ abstract class base { public function get_dir() { global $CFG; + if (!isset($pluginfo->rootdir)) { + return ''; + } + return substr($this->rootdir, strlen($CFG->dirroot)); }