From 2b691d7958e28e5a21af2b9caf3fdd811b015421 Mon Sep 17 00:00:00 2001
From: Brendan Heywood <brendan@catalyst-au.net>
Date: Thu, 8 Aug 2019 13:26:50 +1000
Subject: [PATCH] MDL-66340 setup: Add after_config for after setup.php is
 loaded

---
 lib/setup.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/setup.php b/lib/setup.php
index b1cb7e054ec..df1a2d978a5 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -1042,3 +1042,16 @@ if (false) {
     $OUTPUT = new core_renderer(null, null);
     $PAGE = new moodle_page();
 }
+
+// Allow plugins to callback as soon possible after setup.php is loaded.
+$pluginswithfunction = get_plugins_with_function('after_config', 'lib.php');
+foreach ($pluginswithfunction as $plugins) {
+    foreach ($plugins as $function) {
+        try {
+            $function();
+        } catch (Exception $e) {
+            debugging("Exception calling '$function'", DEBUG_DEVELOPER, $e->getTrace());
+        }
+    }
+}
+
-- 
2.17.1

