MDL-58018 core: Enable read-only sessions for key pages

These pages are often loaded in parallel.
This commit is contained in:
Adam Eijdenberg 2017-02-28 13:21:58 +11:00 committed by Mark Nelson
parent 1c3b89b170
commit 82da35fd51
6 changed files with 17 additions and 0 deletions

View File

@ -26,6 +26,7 @@
*/
define('AJAX_SCRIPT', true);
define('REQUIRE_SESSION_LOCK', false);
/** Include config */
require_once(__DIR__ . '/../../config.php');

View File

@ -28,6 +28,8 @@
*/
define('AJAX_SCRIPT', true);
// Services can declare 'requiresessionlock' in their config located in db/services.php, if not present will default to true.
define('REQUIRE_SESSION_LOCK', false);
if (!empty($_GET['nosessionupdate'])) {
define('NO_SESSION_UPDATE', true);

View File

@ -748,6 +748,7 @@ $functions = array(
'type' => 'read',
'loginrequired' => false,
'ajax' => true,
'requiresessionlock' => true, // Fetching removes from stack.
),
'core_session_touch' => array(
'classname' => 'core\session\external',
@ -1374,6 +1375,7 @@ $functions = array(
'type' => 'read',
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
'requiresessionlock' => false, // We don't modify the session.
),
'core_message_mark_all_notifications_as_read' => array(
'classname' => 'core_message_external',

View File

@ -161,6 +161,11 @@ class external_api {
} else {
$function->loginrequired = true;
}
if (isset($functions[$function->name]['requiresessionlock'])) {
$function->requiresessionlock = $functions[$function->name]['requiresessionlock'];
} else {
$function->requiresessionlock = true;
}
}
return $function;
@ -184,6 +189,11 @@ class external_api {
$externalfunctioninfo = static::external_function_info($function);
// Eventually this should shift into the various handlers and not be handled via config.
if ($externalfunctioninfo->requiresessionlock) {
\core\session\manager::restart_with_write_lock();
}
$currentpage = $PAGE;
$currentcourse = $COURSE;
$response = array();

View File

@ -41,5 +41,6 @@ $functions = array(
'type' => 'read',
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
'requiresessionlock' => false,
),
);

View File

@ -28,6 +28,7 @@
if (!defined('NO_DEBUG_DISPLAY')) {
define('NO_DEBUG_DISPLAY', true);
}
define('REQUIRE_SESSION_LOCK', false); // Plugins will need to acquire a lock if they need one.
require_once('config.php');
require_once('lib/filelib.php');