catalyst / moodle-auth_outage

Planned, graduated user and admin friendly moodle outages
https://moodle.org/plugins/auth_outage
17 stars 34 forks source link

Exception: class 'curl' not found #247

Closed jcharaoui closed 3 years ago

jcharaoui commented 3 years ago

When attempting to preview the static page from a planned outage, the following PHP exception is raised:

PHP message: Default exception handler: Exception: Class 'curl' not found
Debug:
Error code: generalexceptionmessage
* line 62 of /auth/outage/classes/local/outagelib.php: Error thrown
* line 68 of /auth/outage/classes/local/controllers/maintenance_static_page_io.php: call to auth_outage\\local\\outagelib::fetch_page()
* line 64 of /auth/outage/classes/local/controllers/maintenance_static_page.php: call to auth_outage\\local\\controllers\\maintenance_static_page_io::file_get_data()
* line 38 of /auth/outage/preview.php: call to auth_outage\\local\\controllers\\maintenance_static_page::create_from_outage()

This appears to fix the problem:

diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php
index e17dce1..baa7a08 100644
--- a/classes/local/outagelib.php
+++ b/classes/local/outagelib.php
@@ -59,6 +59,8 @@ class outagelib {
     private static $injectcalled = false;

     public static function fetch_page($file) {
+        global $CFG;
+        require_once($CFG->libdir . '/filelib.php');
         $curl = new curl();
         $contents = $curl->get($file);
         $info = $curl->get_info();

Moodle 3.9.4, PHP 7.3.27

AttackVectorDelta commented 3 years ago

We encountered the same problem on our setup - your code fixed the problem. Can you add a PR with your fix?