MDL-44106 add WS_SERVER constant to all web service calls

This will help us hack around some nasty webservice problems,
such as require_login() and it will be used to set proper 'ws' origin
in logged events.
This commit is contained in:
Petr Škoda
2014-03-20 17:28:01 +08:00
parent 9b8555fbea
commit e5d48aad44
10 changed files with 23 additions and 32 deletions
+9
View File
@@ -304,6 +304,11 @@ if (defined('WEB_CRON_EMULATED_CLI')) {
}
}
// All web service requests have WS_SERVER == true.
if (!defined('WS_SERVER')) {
define('WS_SERVER', false);
}
// Detect CLI maintenance mode - this is useful when you need to mess with database, such as during upgrades
if (file_exists("$CFG->dataroot/climaintenance.html")) {
if (!CLI_SCRIPT) {
@@ -745,6 +750,10 @@ if (CLI_SCRIPT) {
// no sessions in CLI scripts possible
define('NO_MOODLE_COOKIES', true);
} else if (WS_SERVER) {
// No sessions possible in web services.
define('NO_MOODLE_COOKIES', true);
} else if (!defined('NO_MOODLE_COOKIES')) {
if (empty($CFG->version) or $CFG->version < 2009011900) {
// no session before sessions table gets created