mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-73500 general: Remove php < 73 conditional code
This commit removes code that only was being executed by php < 73 and it's 100% safe to do so because Moodle 3.11 and up require php 73, hence it was not executed ever. Removed code includes: - ldap_control_paged_result and ldap_control_paged_result_response (that were deprecated in php 73 and have been removed in php 80). - conditional code in the session manager, where some hacks were needed for php < 73. Note that this removes the private function append_samesite_cookie_attribute() completely because it was doinf nothing (first line was returning for php < 73). - Also removed the old session.hash_function ini setting because it was removed in php 71. Kept code includes: - The environmental check_igbinary322_version test has not been removed because it doesn't hurt (always returns "ok" for php 73 sites) and doing it would involve to backport the environment.xml file to 39 and 310. Instead, a note has been added to MDL-71747 in order to get rid of that check for 4.1 and up.
This commit is contained in:
parent
e63604fb6d
commit
5300351831
3 changed files with 65 additions and 209 deletions
|
@ -389,40 +389,21 @@ class enrol_ldap_plugin extends enrol_plugin {
|
|||
$flat_records = array();
|
||||
do {
|
||||
if ($ldap_pagedresults) {
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
// Before 7.3, use this function that was deprecated in PHP 7.4.
|
||||
ldap_control_paged_result($this->ldapconnection, $this->config->pagesize, true, $ldap_cookie);
|
||||
} else {
|
||||
// PHP 7.3 and up, use server controls.
|
||||
$servercontrols = array(array(
|
||||
'oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => array(
|
||||
'size' => $this->config->pagesize, 'cookie' => $ldap_cookie)));
|
||||
}
|
||||
$servercontrols = array(array(
|
||||
'oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => array(
|
||||
'size' => $this->config->pagesize, 'cookie' => $ldap_cookie)));
|
||||
}
|
||||
|
||||
if ($this->config->course_search_sub) {
|
||||
// Use ldap_search to find first user from subtree
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
$ldap_result = @ldap_search($this->ldapconnection, $ldap_context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted);
|
||||
} else {
|
||||
$ldap_result = @ldap_search($this->ldapconnection, $ldap_context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
}
|
||||
$ldap_result = @ldap_search($this->ldapconnection, $ldap_context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
} else {
|
||||
// Search only in this context
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
$ldap_result = @ldap_list($this->ldapconnection, $ldap_context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted);
|
||||
} else {
|
||||
$ldap_result = @ldap_list($this->ldapconnection, $ldap_context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
}
|
||||
$ldap_result = @ldap_list($this->ldapconnection, $ldap_context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
}
|
||||
if (!$ldap_result) {
|
||||
continue; // Next
|
||||
|
@ -431,17 +412,11 @@ class enrol_ldap_plugin extends enrol_plugin {
|
|||
if ($ldap_pagedresults) {
|
||||
// Get next server cookie to know if we'll need to continue searching.
|
||||
$ldap_cookie = '';
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
// Before 7.3, use this function that was deprecated in PHP 7.4.
|
||||
ldap_control_paged_result_response($this->ldapconnection, $ldap_result, $ldap_cookie);
|
||||
} else {
|
||||
// Get next cookie from controls.
|
||||
ldap_parse_result($this->ldapconnection, $ldap_result, $errcode, $matcheddn,
|
||||
$errmsg, $referrals, $controls);
|
||||
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
|
||||
$ldap_cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
|
||||
}
|
||||
// Get next cookie from controls.
|
||||
ldap_parse_result($this->ldapconnection, $ldap_result, $errcode, $matcheddn,
|
||||
$errmsg, $referrals, $controls);
|
||||
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
|
||||
$ldap_cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -806,40 +781,21 @@ class enrol_ldap_plugin extends enrol_plugin {
|
|||
$flat_records = array();
|
||||
do {
|
||||
if ($ldap_pagedresults) {
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
// Before 7.3, use this function that was deprecated in PHP 7.4.
|
||||
ldap_control_paged_result($this->ldapconnection, $this->config->pagesize, true, $ldap_cookie);
|
||||
} else {
|
||||
// PHP 7.3 and up, use server controls.
|
||||
$servercontrols = array(array(
|
||||
'oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => array(
|
||||
'size' => $this->config->pagesize, 'cookie' => $ldap_cookie)));
|
||||
}
|
||||
$servercontrols = array(array(
|
||||
'oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => array(
|
||||
'size' => $this->config->pagesize, 'cookie' => $ldap_cookie)));
|
||||
}
|
||||
|
||||
if ($this->get_config('course_search_sub')) {
|
||||
// Use ldap_search to find first user from subtree
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
$ldap_result = @ldap_search($this->ldapconnection, $context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted);
|
||||
} else {
|
||||
$ldap_result = @ldap_search($this->ldapconnection, $context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
}
|
||||
$ldap_result = @ldap_search($this->ldapconnection, $context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
} else {
|
||||
// Search only in this context
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
$ldap_result = @ldap_list($this->ldapconnection, $context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted);
|
||||
} else {
|
||||
$ldap_result = @ldap_list($this->ldapconnection, $context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
}
|
||||
$ldap_result = @ldap_list($this->ldapconnection, $context,
|
||||
$ldap_search_pattern, $ldap_fields_wanted,
|
||||
0, -1, -1, LDAP_DEREF_NEVER, $servercontrols);
|
||||
}
|
||||
|
||||
if (!$ldap_result) {
|
||||
|
@ -849,17 +805,11 @@ class enrol_ldap_plugin extends enrol_plugin {
|
|||
if ($ldap_pagedresults) {
|
||||
// Get next server cookie to know if we'll need to continue searching.
|
||||
$ldap_cookie = '';
|
||||
// TODO: Remove the old branch of code once PHP 7.3.0 becomes required (Moodle 3.11).
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
// Before 7.3, use this function that was deprecated in PHP 7.4.
|
||||
ldap_control_paged_result_response($this->ldapconnection, $ldap_result, $ldap_cookie);
|
||||
} else {
|
||||
// Get next cookie from controls.
|
||||
ldap_parse_result($this->ldapconnection, $ldap_result, $errcode, $matcheddn,
|
||||
$errmsg, $referrals, $controls);
|
||||
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
|
||||
$ldap_cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
|
||||
}
|
||||
// Get next cookie from controls.
|
||||
ldap_parse_result($this->ldapconnection, $ldap_result, $errcode, $matcheddn,
|
||||
$errmsg, $referrals, $controls);
|
||||
if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) {
|
||||
$ldap_cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue