MDL-37217 files: Stricter type check for curl options
This commit is contained in:
+14
-8
@@ -2935,14 +2935,22 @@ class curl {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set curl options
|
||||
* Set curl options.
|
||||
*
|
||||
* @param array $options If array is null, this function will
|
||||
* reset the options to default value.
|
||||
* Do not use the curl constants to define the options, pass a string
|
||||
* corresponding to that constant. Ie. to set CURLOPT_MAXREDIRS, pass
|
||||
* array('CURLOPT_MAXREDIRS' => 10) or array('maxredirs' => 10) to this method.
|
||||
*
|
||||
* @param array $options If array is null, this function will reset the options to default value.
|
||||
* @return void
|
||||
* @throws coding_exception If an option uses constant value instead of option name.
|
||||
*/
|
||||
public function setopt($options = array()) {
|
||||
if (is_array($options)) {
|
||||
foreach($options as $name => $val){
|
||||
foreach ($options as $name => $val){
|
||||
if (!is_string($name)) {
|
||||
throw new coding_exception('Curl options should be defined using strings, not constant values.');
|
||||
}
|
||||
if (stripos($name, 'CURLOPT_') === false) {
|
||||
$name = strtoupper('CURLOPT_'.$name);
|
||||
}
|
||||
@@ -3067,11 +3075,9 @@ class curl {
|
||||
var_dump($this->header);
|
||||
}
|
||||
|
||||
// set options
|
||||
// Set options.
|
||||
foreach($this->options as $name => $val) {
|
||||
if (is_string($name)) {
|
||||
$name = constant(strtoupper($name));
|
||||
}
|
||||
$name = constant(strtoupper($name));
|
||||
curl_setopt($curl, $name, $val);
|
||||
}
|
||||
return $curl;
|
||||
|
||||
@@ -18,6 +18,10 @@ information provided here is intended especially for developers.
|
||||
only partially deletes data, so wherever it was called extra code was needed to
|
||||
perform the whole deletion process. The function course_delete_module now takes care
|
||||
of the whole process.
|
||||
* curl::setopt() does not accept constant values any more. As it never worked properly,
|
||||
we decided to make the type check stricter. Now, the keys of the array pass must be a string
|
||||
corresponding to the curl constant name.
|
||||
|
||||
|
||||
YUI changes:
|
||||
* M.util.help_icon has been deprecated. Code should be updated to use moodle-core-popuphelp
|
||||
|
||||
Reference in New Issue
Block a user