MDL-70966 various: Under PHP8 empty string is no longer equals to 0

This commit is contained in:
Marina Glancy
2021-02-28 19:16:53 +01:00
parent 4652b66ee4
commit b2d8938431
5 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group {
}
}
$requestvalue=$value;
if ($value == 0) {
if ($value == 0 || $value === '') {
$value = $this->_options['defaulttime'];
if (!$value) {
$value = time();
+1 -1
View File
@@ -745,7 +745,7 @@ class structure {
}
// Check the target page number is OK.
if ($page == 0) {
if ($page == 0 || $page === '') {
$page = 1;
}
if (($moveafterslotnumber > 0 && $page < $this->get_page_number_for_slot($moveafterslotnumber)) ||
@@ -729,7 +729,7 @@ class qformat_gift_test extends question_testcase {
'files' => array(),
),
),
'tolerance' => array(2, 0),
'tolerance' => array(2, ''),
);
// Repeated test for better failure messages.
+1 -1
View File
@@ -1126,7 +1126,7 @@ END;
'format' => FORMAT_HTML),
array('text' => 'Completely wrong.',
'format' => FORMAT_HTML));
$expectedq->tolerance = array(0.001, 1, 0);
$expectedq->tolerance = array(0.001, 1, '');
$this->assert(new question_check_specified_fields_expectation($expectedq), $q);
}
+1 -1
View File
@@ -357,7 +357,7 @@ class qtype_numerical_answer extends question_answer {
public function __construct($id, $answer, $fraction, $feedback, $feedbackformat, $tolerance) {
parent::__construct($id, $answer, $fraction, $feedback, $feedbackformat);
$this->tolerance = abs($tolerance);
$this->tolerance = abs((float)$tolerance);
}
public function get_tolerance_interval() {