mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-58018 core: Enable read-only sessions for key pages
These pages are often loaded in parallel.
This commit is contained in:
parent
1c3b89b170
commit
82da35fd51
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
define('AJAX_SCRIPT', true);
|
||||
define('REQUIRE_SESSION_LOCK', false);
|
||||
|
||||
/** Include config */
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
|
@ -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);
|
||||
|
@ -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',
|
||||
|
@ -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();
|
||||
|
@ -41,5 +41,6 @@ $functions = array(
|
||||
'type' => 'read',
|
||||
'ajax' => true,
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
|
||||
'requiresessionlock' => false,
|
||||
),
|
||||
);
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user