mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-76415 lib: Fixed ${} string interpolation deprecations in phpxmlrpc
Since PHP 8.2, placing the dollar sign outside the curly brace is deprecated when the expression inside the braces resolves to a variable or an expression.
This commit is contained in:
parent
3f850a8a4a
commit
e9822519eb
3 changed files with 18 additions and 15 deletions
|
@ -421,7 +421,7 @@ class Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($wanted)) {
|
if (isset($wanted)) {
|
||||||
return array(0, "Wanted ${wanted}, got ${got} at param ${pno}");
|
return array(0, "Wanted {$wanted}, got {$got} at param {$pno}"); // TODO: Remove this modification in MDL-76415.
|
||||||
} else {
|
} else {
|
||||||
return array(0, "No method signature matches number of parameters");
|
return array(0, "No method signature matches number of parameters");
|
||||||
}
|
}
|
||||||
|
@ -669,7 +669,7 @@ class Server
|
||||||
return new Response(
|
return new Response(
|
||||||
0,
|
0,
|
||||||
PhpXmlRpc::$xmlrpcerr['incorrect_params'],
|
PhpXmlRpc::$xmlrpcerr['incorrect_params'],
|
||||||
PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": ${errStr}"
|
PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": {$errStr}" // TODO: Remove this modification in MDL-76415.
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1020,8 +1020,8 @@ class Server
|
||||||
public static function _xmlrpcs_multicall_error($err)
|
public static function _xmlrpcs_multicall_error($err)
|
||||||
{
|
{
|
||||||
if (is_string($err)) {
|
if (is_string($err)) {
|
||||||
$str = PhpXmlRpc::$xmlrpcstr["multicall_${err}"];
|
$str = PhpXmlRpc::$xmlrpcstr["multicall_{$err}"]; // TODO: Remove this modification in MDL-76415.
|
||||||
$code = PhpXmlRpc::$xmlrpcerr["multicall_${err}"];
|
$code = PhpXmlRpc::$xmlrpcerr["multicall_{$err}"]; // TODO: Remove this modification in MDL-76415.
|
||||||
} else {
|
} else {
|
||||||
$code = $err->faultCode();
|
$code = $err->faultCode();
|
||||||
$str = $err->faultString();
|
$str = $err->faultString();
|
||||||
|
|
|
@ -279,19 +279,19 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||||
case 1:
|
case 1:
|
||||||
switch ($typ) {
|
switch ($typ) {
|
||||||
case static::$xmlrpcBase64:
|
case static::$xmlrpcBase64:
|
||||||
$rs .= "<${typ}>" . base64_encode($val) . "</${typ}>";
|
$rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
break;
|
break;
|
||||||
case static::$xmlrpcBoolean:
|
case static::$xmlrpcBoolean:
|
||||||
$rs .= "<${typ}>" . ($val ? '1' : '0') . "</${typ}>";
|
$rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
break;
|
break;
|
||||||
case static::$xmlrpcString:
|
case static::$xmlrpcString:
|
||||||
// Do NOT use htmlentities, since it will produce named html entities, which are invalid xml
|
// Do NOT use htmlentities, since it will produce named html entities, which are invalid xml
|
||||||
$rs .= "<${typ}>" . $this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</${typ}>";
|
$rs .= "<{$typ}>" . $this->getCharsetEncoder()->encodeEntities($val, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
break;
|
break;
|
||||||
case static::$xmlrpcInt:
|
case static::$xmlrpcInt:
|
||||||
case static::$xmlrpcI4:
|
case static::$xmlrpcI4:
|
||||||
case static::$xmlrpcI8:
|
case static::$xmlrpcI8:
|
||||||
$rs .= "<${typ}>" . (int)$val . "</${typ}>";
|
$rs .= "<{$typ}>" . (int)$val . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
break;
|
break;
|
||||||
case static::$xmlrpcDouble:
|
case static::$xmlrpcDouble:
|
||||||
// avoid using standard conversion of float to string because it is locale-dependent,
|
// avoid using standard conversion of float to string because it is locale-dependent,
|
||||||
|
@ -299,18 +299,18 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||||
// sprintf('%F') could be most likely ok but it fails eg. on 2e-14.
|
// sprintf('%F') could be most likely ok but it fails eg. on 2e-14.
|
||||||
// The code below tries its best at keeping max precision while avoiding exp notation,
|
// The code below tries its best at keeping max precision while avoiding exp notation,
|
||||||
// but there is of course no limit in the number of decimal places to be used...
|
// but there is of course no limit in the number of decimal places to be used...
|
||||||
$rs .= "<${typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, PhpXmlRpc::$xmlpc_double_precision, '.', '')) . "</${typ}>";
|
$rs .= "<{$typ}>" . preg_replace('/\\.?0+$/', '', number_format((double)$val, PhpXmlRpc::$xmlpc_double_precision, '.', '')) . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
break;
|
break;
|
||||||
case static::$xmlrpcDateTime:
|
case static::$xmlrpcDateTime:
|
||||||
if (is_string($val)) {
|
if (is_string($val)) {
|
||||||
$rs .= "<${typ}>${val}</${typ}>";
|
$rs .= "<{$typ}>{$val}</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
} elseif (is_a($val, 'DateTime') || is_a($val, 'DateTimeInterface')) {
|
} elseif (is_a($val, 'DateTime') || is_a($val, 'DateTimeInterface')) {
|
||||||
$rs .= "<${typ}>" . $val->format('Ymd\TH:i:s') . "</${typ}>";
|
$rs .= "<{$typ}>" . $val->format('Ymd\TH:i:s') . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
} elseif (is_int($val)) {
|
} elseif (is_int($val)) {
|
||||||
$rs .= "<${typ}>" . date('Ymd\TH:i:s', $val) . "</${typ}>";
|
$rs .= "<{$typ}>" . date('Ymd\TH:i:s', $val) . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
} else {
|
} else {
|
||||||
// not really a good idea here: but what should we output anyway? left for backward compat...
|
// not really a good idea here: but what should we output anyway? left for backward compat...
|
||||||
$rs .= "<${typ}>${val}</${typ}>";
|
$rs .= "<{$typ}>{$val}</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case static::$xmlrpcNull:
|
case static::$xmlrpcNull:
|
||||||
|
@ -323,7 +323,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||||
default:
|
default:
|
||||||
// no standard type value should arrive here, but provide a possibility
|
// no standard type value should arrive here, but provide a possibility
|
||||||
// for xmlrpc values of unknown type...
|
// for xmlrpc values of unknown type...
|
||||||
$rs .= "<${typ}>${val}</${typ}>";
|
$rs .= "<{$typ}>{$val}</{$typ}>"; // TODO: Remove this modification in MDL-76415.
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
|
@ -19,4 +19,7 @@ To update:
|
||||||
Current version imported: 4.8.1 (c74cc31)
|
Current version imported: 4.8.1 (c74cc31)
|
||||||
|
|
||||||
Local changes:
|
Local changes:
|
||||||
* readme_moodle.txt - this file ;-)
|
* 2023/01/26 - Server.php and Value.php files have minor changes for PHP 8.2 compatibility. See MDL-76415 for more details.
|
||||||
|
Since version 4.9.1, the phpxmlrpc already has the fix, so if someone executing the upgrading version and
|
||||||
|
it has the patch, please ignore this note.
|
||||||
|
* readme_moodle.txt - this file ;-)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue