mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 08:00:37 +01:00
Merge branch 'MDL-76356_401' of https://github.com/stronk7/moodle into MOODLE_401_STABLE
This commit is contained in:
commit
833bc53bbb
@ -187,7 +187,7 @@ class provider_test extends provider_testcase {
|
||||
$writer = writer::with_context($context);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
if ($context->contextlevel == CONTEXT_MODULE) {
|
||||
if ($data = $writer->get_data($subcontextstudent)) {
|
||||
if ($data = (array)$writer->get_data($subcontextstudent)) {
|
||||
$this->assertEquals($user->id, reset($data)->userid);
|
||||
}
|
||||
if ($data = (array)$writer->get_data($subcontextrc)) {
|
||||
|
@ -278,7 +278,7 @@ if (empty($parallelrun)) {
|
||||
// Print combined run o/p from processes.
|
||||
$exitcodes = print_combined_run_output($processes, $stoponfail);
|
||||
// Time to finish run.
|
||||
$time = round(microtime(true) - $time, 1);
|
||||
$time = round(microtime(true) - $time, 0);
|
||||
echo "Finished in " . gmdate("G\h i\m s\s", $time) . PHP_EOL . PHP_EOL;
|
||||
ksort($exitcodes);
|
||||
|
||||
|
@ -278,7 +278,7 @@ class page_agreedocs implements renderable, templatable {
|
||||
$cache = \cache::make('core', 'presignup');
|
||||
$cachekey = 'tool_policy_viewedpolicies';
|
||||
|
||||
$viewedpolicies = $cache->get($cachekey);
|
||||
$viewedpolicies = $cache->get($cachekey) ?: [];
|
||||
if (!empty($viewedpolicies)) {
|
||||
// Get the list of the policies docs which the user haven't viewed during this session.
|
||||
$pendingpolicies = array_diff($currentpolicyversionids, $viewedpolicies);
|
||||
|
@ -99,7 +99,7 @@ class calculation_info {
|
||||
$samplekey = self::get_sample_key($uniquesampleid);
|
||||
|
||||
// Update the cached data adding the new indicator data.
|
||||
$cacheddata = $cache->get($samplekey);
|
||||
$cacheddata = $cache->get($samplekey) ?: [];
|
||||
$cacheddata[$calculableclass] = $infokeys;
|
||||
$cache->set($samplekey, $cacheddata);
|
||||
}
|
||||
|
@ -305,7 +305,9 @@ class helper_test extends \advanced_testcase {
|
||||
$this->assertTrue(empty($messages->info));
|
||||
|
||||
// Add an some messages manually and check they are still there.
|
||||
$messages->error = [];
|
||||
$messages->error['error1'] = 'Testing ERROR message';
|
||||
$messages->info = [];
|
||||
$messages->info['info1'] = 'Testing INFO message';
|
||||
$messages->info['info2'] = 'Testing INFO message';
|
||||
helper::get_messages($messages, $factory);
|
||||
|
@ -893,7 +893,7 @@ class behat_config_util {
|
||||
&& (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST)) {
|
||||
echo "Bucket weightings:\n";
|
||||
foreach ($weights as $k => $weight) {
|
||||
echo $k + 1 . ": " . str_repeat('*', 70 * $nbuckets * $weight / $totalweight) . PHP_EOL;
|
||||
echo $k + 1 . ": " . str_repeat('*', (int)(70 * $nbuckets * $weight / $totalweight)) . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,10 +459,8 @@ class address_manager {
|
||||
*/
|
||||
protected function pack_int($int) {
|
||||
if (PHP_INT_SIZE === 8) {
|
||||
$left = 0xffffffff00000000;
|
||||
$right = 0x00000000ffffffff;
|
||||
$l = ($int & $left) >>32;
|
||||
$r = $int & $right;
|
||||
$l = intdiv($int, pow(2, 32)); // 32-bit integer quotient.
|
||||
$r = $int % pow(2, 32); // 32-bit integer remaining.
|
||||
|
||||
return pack('NN', $l, $r);
|
||||
} else {
|
||||
|
@ -285,7 +285,8 @@ abstract class base {
|
||||
}
|
||||
|
||||
if (isset($plugin->incompatible) && $plugin->incompatible !== null) {
|
||||
if ((ctype_digit($plugin->incompatible) || is_int($plugin->incompatible)) && (int) $plugin->incompatible > 0) {
|
||||
if (((is_string($plugin->incompatible) && ctype_digit($plugin->incompatible)) || is_int($plugin->incompatible))
|
||||
&& (int) $plugin->incompatible > 0) {
|
||||
$this->pluginincompatible = intval($plugin->incompatible);
|
||||
} else {
|
||||
throw new coding_exception('Incorrect syntax in plugin incompatible declaration in '."$this->name");
|
||||
|
@ -511,7 +511,7 @@ class redis extends handler {
|
||||
// time. If it is too small we will poll too much and if it is
|
||||
// too large we will waste time waiting for no reason. 100ms is
|
||||
// the default starting point.
|
||||
$delay = rand($this->lockretry, $this->lockretry * 1.1);
|
||||
$delay = rand($this->lockretry, (int)($this->lockretry * 1.1));
|
||||
} else {
|
||||
// If we don't get a lock within 5 seconds then there must be a
|
||||
// very long lived process holding the lock so throttle back to
|
||||
|
@ -1055,7 +1055,7 @@ class completion_info {
|
||||
if (!isset($this->course->cacherev)) {
|
||||
$this->course = get_course($this->course_id);
|
||||
}
|
||||
if ($cacheddata = $completioncache->get($key)) {
|
||||
if ($cacheddata = ($completioncache->get($key) ?: [])) {
|
||||
if ($cacheddata['cacherev'] != $this->course->cacherev) {
|
||||
// Course structure has been changed since the last caching, forget the cache.
|
||||
$cacheddata = array();
|
||||
|
@ -216,8 +216,8 @@ function process_new_icon($context, $component, $filearea, $itemid, $originalfil
|
||||
$im3 = imagecreate(512, 512);
|
||||
}
|
||||
|
||||
$cx = $image->width / 2;
|
||||
$cy = $image->height / 2;
|
||||
$cx = floor($image->width / 2);
|
||||
$cy = floor($image->height / 2);
|
||||
|
||||
if ($image->width < $image->height) {
|
||||
$half = floor($image->width / 2.0);
|
||||
|
@ -229,7 +229,7 @@ class custom_completion extends activity_custom_completion {
|
||||
*/
|
||||
protected static function get_completionattendance_value(stdClass $log): int {
|
||||
$summary = json_decode($log->meta);
|
||||
return empty($summary->data->duration) ? 0 : $summary->data->duration / 60;
|
||||
return empty($summary->data->duration) ? 0 : (int)($summary->data->duration / 60);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -493,7 +493,7 @@ class attempt {
|
||||
* @return int|null the scaled value
|
||||
*/
|
||||
public function get_scaled(): ?int {
|
||||
return $this->record->scaled;
|
||||
return is_null($this->record->scaled) ? $this->record->scaled : (int)$this->record->scaled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,8 +228,9 @@ class calculator {
|
||||
|
||||
$this->sumofmarkvariance += $this->stats->for_slot($slot)->markvariance;
|
||||
|
||||
if ($this->stats->for_slot($slot)->covariancewithoverallmark >= 0) {
|
||||
$sumofcovariancewithoverallmark += sqrt($this->stats->for_slot($slot)->covariancewithoverallmark);
|
||||
$covariancewithoverallmark = $this->stats->for_slot($slot)->covariancewithoverallmark;
|
||||
if (null !== $covariancewithoverallmark && $covariancewithoverallmark >= 0) {
|
||||
$sumofcovariancewithoverallmark += sqrt($covariancewithoverallmark);
|
||||
}
|
||||
}
|
||||
$this->progress->end_progress();
|
||||
|
@ -917,8 +917,8 @@ abstract class question_utils {
|
||||
'converted to roman numerals.', $number);
|
||||
}
|
||||
|
||||
return self::$thousands[$number / 1000 % 10] . self::$hundreds[$number / 100 % 10] .
|
||||
self::$tens[$number / 10 % 10] . self::$units[$number % 10];
|
||||
return self::$thousands[floor($number / 1000) % 10] . self::$hundreds[floor($number / 100) % 10] .
|
||||
self::$tens[floor($number / 10) % 10] . self::$units[$number % 10];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,7 +239,7 @@ class qtype_multianswer_textfield_renderer extends qtype_multianswer_subq_render
|
||||
foreach ($subq->answers as $ans) {
|
||||
$size = max($size, core_text::strlen(trim($ans->answer)));
|
||||
}
|
||||
$size = min(60, round($size + rand(0, $size * 0.15)));
|
||||
$size = min(60, round($size + rand(0, (int)($size * 0.15))));
|
||||
// The rand bit is to make guessing harder.
|
||||
|
||||
$inputattributes = array(
|
||||
|
@ -307,7 +307,7 @@ abstract class engine {
|
||||
if ($now - $lastprogress >= manager::DISPLAY_INDEXING_PROGRESS_EVERY) {
|
||||
$lastprogress = $now;
|
||||
// The first date format is the same used in cron_trace_time_and_memory().
|
||||
$options['progress']->output(date('H:i:s', $now) . ': Done to ' . userdate(
|
||||
$options['progress']->output(date('H:i:s', (int)$now) . ': Done to ' . userdate(
|
||||
$lastindexeddoc, get_string('strftimedatetimeshort', 'langconfig')), 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user