MDL-37598 Proceed full setup in YUI serving files if needed
authorDavid Mudrák <david@moodle.com>
Thu, 24 Jan 2013 17:39:24 +0000 (18:39 +0100)
committerDavid Mudrák <david@moodle.com>
Mon, 11 Feb 2013 15:35:16 +0000 (16:35 +0100)
When serving Moodle YUI files, including just moodlelib.php is not enough
any more. We need the full setup in order to use MUC.

Please note that cookies are disabled in these two scripts. This may make
cache_store::MODE_SESSION caches unavailable. We do not expect they will
be needed here.

theme/yui_combo.php
theme/yui_image.php

index bd19b50..f7912ba 100644 (file)
@@ -82,10 +82,11 @@ foreach ($parts as $part) {
     //debug($bits);
     $version = array_shift($bits);
     if ($version === 'moodle') {
-        //TODO: this is a ugly hack because we should not load any libs here!
-        if (!defined('MOODLE_INTERNAL')) {
-            define('MOODLE_INTERNAL', true);
-            require_once($CFG->libdir.'/moodlelib.php');
+        if (!defined('ABORT_AFTER_CONFIG_CANCEL')) {
+            define('ABORT_AFTER_CONFIG_CANCEL', true);
+            define('NO_UPGRADE_CHECK', true);
+            define('NO_MOODLE_COOKIES', true);
+            require($CFG->libdir.'/setup.php');
         }
         $revision = (int)array_shift($bits);
         if ($revision === -1) {
index 4477a9c..3787f01 100644 (file)
@@ -43,9 +43,12 @@ $parts = explode('/', $path);
 $version = array_shift($parts);
 
 if ($version == 'moodle' && count($parts) >= 3) {
-    //TODO: this is a ugly hack because we should not load any libs here!
-    define('MOODLE_INTERNAL', true);
-    require_once($CFG->libdir.'/moodlelib.php');
+    if (!defined('ABORT_AFTER_CONFIG_CANCEL')) {
+        define('ABORT_AFTER_CONFIG_CANCEL', true);
+        define('NO_UPGRADE_CHECK', true);
+        define('NO_MOODLE_COOKIES', true);
+        require($CFG->libdir.'/setup.php');
+    }
     $frankenstyle = array_shift($parts);
     $module = array_shift($parts);
     $image = array_pop($parts);