Merge branch 'MDL-76415-master' of https://github.com/meirzamoodle/moodle

This commit is contained in:
Andrew Nicols
2023-02-16 11:31:42 +08:00
31 changed files with 76 additions and 62 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ require_capability('moodle/site:configview', context_system::instance());
$jsdocdir = "{$CFG->dirroot}/jsdoc";
if (file_exists($jsdocdir) && is_dir($jsdocdir)) {
$relativepath = get_file_argument();
redirect(new moodle_url("/jsdoc/${relativepath}"));
redirect(new moodle_url("/jsdoc/{$relativepath}"));
}
$PAGE->set_pagelayout('base');
@@ -114,7 +114,7 @@ class behat_block_site_main_menu extends behat_base {
protected function get_site_menu_activity_element($element, $selectortype, $activityname) {
$activitynode = $this->get_site_menu_activity_node($activityname);
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '${activityname}'");
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '{$activityname}'");
return $this->find($selectortype, $element, $exception, $activitynode);
}
@@ -122,7 +122,7 @@ class behat_block_social_activities extends behat_base {
protected function get_social_block_activity_element($element, $selectortype, $activityname) {
$activitynode = $this->get_social_block_activity_node($activityname);
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '${activityname}'");
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '{$activityname}'");
return $this->find($selectortype, $element, $exception, $activitynode);
}
+1 -1
View File
@@ -1173,7 +1173,7 @@ class behat_course extends behat_base {
protected function get_activity_element($element, $selectortype, $activityname) {
$activitynode = $this->get_activity_node($activityname);
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '${activityname}'");
$exception = new ElementNotFoundException($this->getSession(), "'{$element}' '{$selectortype}' in '{$activityname}'");
return $this->find($selectortype, $element, $exception, $activitynode);
}
@@ -97,7 +97,7 @@ class select extends screen {
$types = gradereport_singleview\report\singleview::valid_screens();
foreach ($types as $type) {
$classname = "gradereport_singleview\\local\\screen\\${type}";
$classname = "gradereport_singleview\\local\\screen\\{$type}";
$screen = new $classname($this->courseid, null, $this->groupid);
@@ -109,7 +109,7 @@ class singleview extends grade_report {
$this->setup_item_selector($itemtype, $itemid);
$screenclass = "\\gradereport_singleview\\local\\screen\\${itemtype}";
$screenclass = "\\gradereport_singleview\\local\\screen\\{$itemtype}";
$this->screen = new $screenclass($courseid, $itemid, $this->currentgroup);
+1 -1
View File
@@ -60,7 +60,7 @@ class lock_config {
$dbtype = clean_param($DB->get_dbfamily(), PARAM_ALPHA);
// DB Specific lock factory is preferred - should support auto-release.
$lockfactoryclass = "\\core\\lock\\${dbtype}_lock_factory";
$lockfactoryclass = "\\core\\lock\\{$dbtype}_lock_factory";
if (!class_exists($lockfactoryclass)) {
$lockfactoryclass = '\core\lock\file_lock_factory';
}
+4 -4
View File
@@ -6292,10 +6292,10 @@ EOD;
['description' => $description, 'version' => $version] = $DB->get_server_info();
// MariaDB RPL_VERSION_HACK sanity check: "5.5.5" has never been released!
$this->assertNotSame('5.5.5', $version,
"Found invalid DB server version i.e. RPL_VERSION_HACK: '${version}' (${description}).");
"Found invalid DB server version i.e. RPL_VERSION_HACK: '{$version}' ({$description}).");
// DB version format is: "X.Y.Z".
$this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $version,
"Found invalid DB server version format: '${version}' (${description}).");
"Found invalid DB server version format: '{$version}' ({$description}).");
// Alter the DB options to force the read from DB and check for the same assertions above.
$cfg->dboptions['versionfromdb'] = true;
@@ -6309,9 +6309,9 @@ EOD;
$this->assertTrue($rcm->invokeArgs($db2, []), 'Invalid test state!');
['description' => $description, 'version' => $version] = $db2->get_server_info();
$this->assertNotSame('5.5.5', $version,
"Found invalid DB server version when reading version from DB i.e. RPL_VERSION_HACK: '${version}' (${description}).");
"Found invalid DB server version when reading version from DB i.e. RPL_VERSION_HACK: '{$version}' ({$description}).");
$this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', $version,
"Found invalid DB server version format when reading version from DB: '${version}' (${description}).");
"Found invalid DB server version format when reading version from DB: '{$version}' ({$description}).");
$db2->dispose();
}
}
@@ -49,13 +49,13 @@ class behat_editor_atto extends behat_base implements \core_behat\settable_edito
public function set_editor_value(string $editorid, string $value): void {
$js = <<<EOF
(function() {
const editableEditor = document.getElementById("${editorid}editable");
const editableEditor = document.getElementById("{$editorid}editable");
if (editableEditor && editableEditor.classList.contains('editor_atto_content')) {
editableEditor.innerHTML = "${value}";
editableEditor.innerHTML = "{$value}";
}
const editor = document.getElementById("${editorid}");
const editor = document.getElementById("{$editorid}");
if (editor) {
editor.value = "${value}";
editor.value = "{$value}";
}
})();
EOF;
@@ -37,9 +37,9 @@ class behat_editor_textarea extends behat_base implements \core_behat\settable_e
public function set_editor_value(string $editorid, string $value): void {
$js = <<<EOF
(function() {
const editor = document.getElementById("${editorid}");
const editor = document.getElementById("{$editorid}");
if (editor && editor.tagName.toLowerCase() === 'textarea') {
editor.value = "${value}";
editor.value = "{$value}";
}
})();
EOF;
+2 -2
View File
@@ -226,8 +226,8 @@ class editor extends \texteditor {
M.util.js_pending('editor_tiny/editor');
require(['editor_tiny/editor'], (Tiny) => {
Tiny.setupForElementId({
elementId: "${elementid}",
options: ${configoptions},
elementId: "{$elementid}",
options: {$configoptions},
});
M.util.js_complete('editor_tiny/editor');
});
@@ -50,7 +50,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
protected function execute_javascript_for_editor(string $editorid, string $code): void {
$js = <<<EOF
require(['editor_tiny/editor'], (editor) => {
const instance = editor.getInstanceForElementId('${editorid}');
const instance = editor.getInstanceForElementId('{$editorid}');
{$code}
});
EOF;
@@ -72,9 +72,9 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
$js = <<<EOF
return new Promise((resolve, reject) => {
require(['editor_tiny/editor'], (editor) => {
const instance = editor.getInstanceForElementId('${editorid}');
const instance = editor.getInstanceForElementId('{$editorid}');
if (!instance) {
reject("Instance '${editorid}' not found");
reject("Instance '{$editorid}' not found");
}
{$code}
@@ -101,7 +101,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
}
$this->execute_javascript_for_editor($editorid, <<<EOF
instance.setContent('${value}');
instance.setContent('{$value}');
instance.undoManager.add();
EOF);
}
@@ -189,7 +189,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
$js = <<<EOF
const container = instance.getContainer();
if (!container.id) {
container.id = '${targetid}';
container.id = '{$targetid}';
}
resolve(container.id);
EOF;
@@ -228,7 +228,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
// Ensure that a name is set on the iframe relating to the editorid.
$js = <<<EOF
if (!instance.iframeElement.name) {
instance.iframeElement.name = '${editorid}';
instance.iframeElement.name = '{$editorid}';
}
resolve(instance.iframeElement.name);
EOF;
@@ -327,7 +327,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
// Ensure that a name is set on the iframe relating to the editorid.
$js = <<<EOF
const element = instance.dom.select("${textlocator}")[${position}];
const element = instance.dom.select("{$textlocator}")[{$position}];
instance.selection.select(element);
EOF;
@@ -427,7 +427,7 @@ class behat_editor_tiny extends behat_base implements \core_behat\settable_edito
$js = <<<EOF
const editorDocument = instance.getDoc();
const element = editorDocument.evaluate(
"${xpath}",
"{$xpath}",
editorDocument,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
+6 -1
View File
@@ -1,8 +1,13 @@
Current version is 0.8.0
# Download latest stable version from https://github.com/php-ai/php-ml
# Download latest stable version from https://github.com/jorgecasas/php-ml
# Remove all files but:
* src/
* LICENSE
# Copy content of src/ to /path/to/moodle/lib/mlbackend/php/phpml/src/Phpml
# Copy LICENSE file to /path/to/moodle/lib/mlbackend/php/phpml
# Applied patch https://github.com/jorgecasas/php-ml/pull/5
2023/01/26
----------
- Changing the repository URL to https://github.com/jorgecasas/php-ml
@@ -386,9 +386,9 @@ class DecisionTree implements Classifier
$median = Mean::median($values);
foreach ($values as &$value) {
if ($value <= $median) {
$value = "<= ${median}";
$value = "<= {$median}";
} else {
$value = "> ${median}";
$value = "> {$median}";
}
}
}
@@ -122,7 +122,7 @@ class DecisionTreeLeaf
public function getHTML(?array $columnNames = null): string
{
if ($this->isTerminal) {
$value = "<b>${this}->classValue</b>";
$value = "<b>{$this}->classValue</b>";
} else {
$value = $this->value;
if ($columnNames !== null) {
@@ -132,13 +132,13 @@ class DecisionTreeLeaf
}
if ((bool) preg_match('/^[<>=]{1,2}/', (string) $value) === false) {
$value = "=${value}";
$value = "={$value}";
}
$value = "<b>${col} ${value}</b><br>Gini: ".number_format($this->giniIndex, 2);
$value = "<b>{$col} {$value}</b><br>Gini: ".number_format($this->giniIndex, 2);
}
$str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>${value}</td></tr>";
$str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>{$value}</td></tr>";
if ($this->leftLeaf !== null || $this->rightLeaf !== null) {
$str .= '<tr>';
@@ -87,7 +87,7 @@ class DecisionStump extends WeightedClassifier
public function __toString(): string
{
return "IF ${this}->column ${this}->operator ${this}->value ".
return "IF {$this->column} {$this->operator} {$this->value} ".
'THEN '.$this->binaryLabels[0].' '.
'ELSE '.$this->binaryLabels[1];
}
@@ -25,7 +25,7 @@ class StopWords
public static function factory(string $language = 'English'): self
{
$className = __NAMESPACE__."\\StopWords\\${language}";
$className = __NAMESPACE__."\\StopWords\\{$language}";
if (!class_exists($className)) {
throw new InvalidArgumentException(sprintf('Can\'t find "%s" language for StopWords', $language));
@@ -157,7 +157,7 @@ trait OneVsRest
*/
private function binarizeTargets(array $targets, $label): array
{
$notLabel = "not_${label}";
$notLabel = "not_{$label}";
foreach ($targets as $key => $target) {
$targets[$key] = $target == $label ? $label : $notLabel;
}
+6
View File
@@ -13,3 +13,9 @@ Instructions
4. Download the latest release.
5. Unzip it in lib as php-jwt.
6. Update entry for this library in lib/thirdpartylibs.xml.
2023/01/26
----------
- src/JWT.php file has minor changes for PHP 8.2 compatibility. See MDL-76415 for more details.
Since version v6.3.1, the php-jwt already has the fix, so if someone executing the upgrading version and
it has the patch, please ignore this note.
+1 -1
View File
@@ -136,7 +136,7 @@ class JWT
// OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures
$sig = self::signatureToDER($sig);
}
if (!self::verify("${headb64}.${bodyb64}", $sig, $key->getKeyMaterial(), $header->alg)) {
if (!self::verify("{$headb64}.{$bodyb64}", $sig, $key->getKeyMaterial(), $header->alg)) { // TODO: Remove this modification in MDL-76415.
throw new SignatureInvalidException('Signature verification failed');
}
+1 -1
View File
@@ -53,7 +53,7 @@ function moodle_minimum_php_version_is_met($haltexecution = false) {
if (version_compare(PHP_VERSION, $minimumversion) < 0) {
if ($haltexecution) {
$error = "Moodle ${moodlerequirementchanged} or later requires at least PHP ${minimumversion} "
$error = "Moodle {$moodlerequirementchanged} or later requires at least PHP {$minimumversion} "
. "(currently using version " . PHP_VERSION .").\n"
. "Some servers may have multiple PHP versions installed, are you using the correct executable?\n";
+4 -4
View File
@@ -421,7 +421,7 @@ class Server
}
}
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 {
return array(0, "No method signature matches number of parameters");
}
@@ -669,7 +669,7 @@ class Server
return new Response(
0,
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)
{
if (is_string($err)) {
$str = PhpXmlRpc::$xmlrpcstr["multicall_${err}"];
$code = PhpXmlRpc::$xmlrpcerr["multicall_${err}"];
$str = PhpXmlRpc::$xmlrpcstr["multicall_{$err}"]; // TODO: Remove this modification in MDL-76415.
$code = PhpXmlRpc::$xmlrpcerr["multicall_{$err}"]; // TODO: Remove this modification in MDL-76415.
} else {
$code = $err->faultCode();
$str = $err->faultString();
+10 -10
View File
@@ -279,19 +279,19 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
case 1:
switch ($typ) {
case static::$xmlrpcBase64:
$rs .= "<${typ}>" . base64_encode($val) . "</${typ}>";
$rs .= "<{$typ}>" . base64_encode($val) . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
break;
case static::$xmlrpcBoolean:
$rs .= "<${typ}>" . ($val ? '1' : '0') . "</${typ}>";
$rs .= "<{$typ}>" . ($val ? '1' : '0') . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
break;
case static::$xmlrpcString:
// 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;
case static::$xmlrpcInt:
case static::$xmlrpcI4:
case static::$xmlrpcI8:
$rs .= "<${typ}>" . (int)$val . "</${typ}>";
$rs .= "<{$typ}>" . (int)$val . "</{$typ}>"; // TODO: Remove this modification in MDL-76415.
break;
case static::$xmlrpcDouble:
// 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.
// 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...
$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;
case static::$xmlrpcDateTime:
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')) {
$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)) {
$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 {
// 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;
case static::$xmlrpcNull:
@@ -323,7 +323,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
default:
// no standard type value should arrive here, but provide a possibility
// for xmlrpc values of unknown type...
$rs .= "<${typ}>${val}</${typ}>";
$rs .= "<{$typ}>{$val}</{$typ}>"; // TODO: Remove this modification in MDL-76415.
}
break;
case 3:
+4 -1
View File
@@ -19,4 +19,7 @@ To update:
Current version imported: 4.8.1 (c74cc31)
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 ;-)
+1 -1
View File
@@ -903,7 +903,7 @@ class component_test extends advanced_testcase {
// Iterate over all apis and perform more validations.
foreach ($apis as $apiname => $attributes) {
// Message, to be used later and easier finding the problem.
$message = "Validation problem found with API: ${apiname}";
$message = "Validation problem found with API: {$apiname}";
$this->assertIsObject($attributes, $message);
$this->assertMatchesRegularExpression('/^[a-z][a-z0-9]+$/', $apiname, $message);
+1 -1
View File
@@ -881,7 +881,7 @@ EXPECTED;
$url1 = "{$CFG->wwwroot}/draftfile.php/5/user/draft/99999999/test1.jpg";
$url2 = "{$CFG->wwwroot}/draftfile.php/5/user/draft/99999998/test2.jpg";
$html = "<p>This is a test.</p><p><img src=\"${url1}\" alt=\"\" role=\"presentation\"></p>
$html = "<p>This is a test.</p><p><img src=\"{$url1}\" alt=\"\" role=\"presentation\"></p>
<br>Test content.<p></p><p><img src=\"{$url2}\" alt=\"\" width=\"2048\" height=\"1536\"
role=\"presentation\" class=\"img-fluid atto_image_button_text-bottom\"><br></p>";
$draftareas = array(
+1 -1
View File
@@ -70,7 +70,7 @@ if ($action === 'pollconversions') {
// Get a lock for the PDF/Image conversion of the assignment files.
$lockfactory = \core\lock\lock_config::get_lock_factory('assignfeedback_editpdf_pollconversions');
$resource = "user:${userid},assignmentid:${assignmentid},attemptnumber:${attemptnumber}";
$resource = "user:{$userid},assignmentid:{$assignmentid},attemptnumber:{$attemptnumber}";
$lock = $lockfactory->get_lock($resource, 0);
// Could not get lock, send back JSON to poll again.
+1 -1
View File
@@ -658,7 +658,7 @@ class provider implements
LEFT JOIN {groups} g ON g.id = d.groupid
LEFT JOIN {forum_discussion_subs} dsub ON dsub.discussion = d.id AND dsub.userid = :dsubuserid
LEFT JOIN {forum_posts} p ON p.discussion = d.id
WHERE f.id ${foruminsql}
WHERE f.id {$foruminsql}
AND (
d.userid = :discussionuserid OR
p.userid = :postuserid OR
+1 -1
View File
@@ -99,7 +99,7 @@ class portfolio_plugin_googledocs extends portfolio_plugin_push_base {
// Create each of the directories in Google Drive that we need.
foreach ($directories as $directory) {
// Update the current path for this file.
$path .= "${directory}/";
$path .= "{$directory}/";
if (!isset($directoryids[$path])) {
// This directory hasn't been created yet so let's go ahead and create it.
+1 -1
View File
@@ -100,7 +100,7 @@ abstract class provider_testcase extends \advanced_testcase {
* @return string
*/
protected function get_provider_classname($component) {
$classname = "\\${component}\\privacy\\provider";
$classname = "\\{$component}\\privacy\\provider";
if (!class_exists($classname)) {
throw new \coding_exception("{$component} does not implement any provider");
+2 -2
View File
@@ -66,11 +66,11 @@ class report_eventlist_list_generator {
if ($detail) {
$reflectionclass = new ReflectionClass($event);
if (!$reflectionclass->isAbstract()) {
$eventinformation = self::format_data($eventinformation, "\\${event}");
$eventinformation = self::format_data($eventinformation, "\\{$event}");
}
} else {
$parts = explode('\\', $event);
$eventinformation["\\${event}"] = array_shift($parts);
$eventinformation["\\{$event}"] = array_shift($parts);
}
}
}