mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-65187 core_hub: truncate registration request, use post
This commit is contained in:
parent
04645f4e9b
commit
ec8453c122
@ -88,7 +88,8 @@ class api {
|
||||
|
||||
$curl = new curl();
|
||||
$serverurl = HUB_MOODLEORGHUBURL . "/local/hub/webservice/webservices.php";
|
||||
$curloutput = @json_decode($curl->get($serverurl, $params), true);
|
||||
$query = http_build_query($params, '', '&');
|
||||
$curloutput = @json_decode($curl->post($serverurl, $query), true);
|
||||
$info = $curl->get_info();
|
||||
if ($curl->get_errno()) {
|
||||
// Connection error.
|
||||
|
@ -350,6 +350,13 @@ class registration {
|
||||
$record['timemodified'] = time();
|
||||
$DB->update_record('registration_hubs', $record);
|
||||
self::$registration = null;
|
||||
|
||||
$siteinfo = self::get_site_info();
|
||||
if (strlen(http_build_query($siteinfo)) > 1800) {
|
||||
// Update registration again because the initial request was too long and could have been truncated.
|
||||
api::update_registration($siteinfo);
|
||||
self::$registration = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -397,10 +404,22 @@ class registration {
|
||||
self::$registration = null;
|
||||
}
|
||||
|
||||
$params = ['token' => $hub->token] + self::get_site_info();
|
||||
$params = self::get_site_info();
|
||||
|
||||
// The most conservative limit for the redirect URL length is 2000 characters. Only pass parameters before
|
||||
// we reach this limit. The next registration update will update all fields.
|
||||
// We will also update registration after we receive confirmation from moodle.net.
|
||||
$url = new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php',
|
||||
['token' => $hub->token, 'url' => $params['url']]);
|
||||
foreach ($params as $key => $value) {
|
||||
if (strlen($url->out(false, [$key => $value])) > 2000) {
|
||||
break;
|
||||
}
|
||||
$url->param($key, $value);
|
||||
}
|
||||
|
||||
$SESSION->registrationredirect = $returnurl;
|
||||
redirect(new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php', $params));
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,7 @@ class site_registration_form extends \moodleform {
|
||||
$mform->addElement('header', 'moodle', get_string('registrationinfo', 'hub'));
|
||||
|
||||
$mform->addElement('text', 'name', get_string('sitename', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
array('class' => 'registration_textfield', 'maxlength' => 255));
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->addHelpButton('name', 'sitename', 'hub');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user