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
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
// Make sure OPcache does not strip comments, we need them for Zend!
if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
// Make sure OPcache does not strip comments, we need them for Zend!
if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
require('../../config.php');
require_once("$CFG->dirroot/webservice/rest/locallib.php");
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
require('../../config.php');
require_once("$CFG->dirroot/webservice/rest/locallib.php");
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
// Make sure OPcache does not strip comments, we need them for Zend!
if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
// Make sure OPcache does not strip comments, we need them for Zend!
if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
+6
View File
@@ -3,6 +3,12 @@ information provided here is intended especially for developers.
This information is intended for authors of webservices, not people writing webservice clients.
=== 2.7 ===
* All webservice server.php and simpleserver.php scripts must define('WS_SERVER', true)
before including config.php file.
=== 2.6 ===
* webservice/upload.php
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
// Make sure OPcache does not strip comments, we need them for Zend!
if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {
+1 -4
View File
@@ -28,10 +28,7 @@
*/
define('NO_DEBUG_DISPLAY', true);
/**
* NO_MOODLE_COOKIES - no cookies with web service
*/
define('NO_MOODLE_COOKIES', true);
define('WS_SERVER', true);
// Make sure OPcache does not strip comments, we need them for Zend!
if (ini_get('opcache.enable') and strtolower(ini_get('opcache.enable')) !== 'off') {