From 927010240f410c8e798ea629cff7a25bb9be491b Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 15 Jan 2012 21:49:30 +0100 Subject: [PATCH] MDL-31006 some more PHP54 notices PHP54 compatibility - PhpStorm IDE is the best tool for this kind of work!! --- backup/restorelib.php | 1 + backup/util/helper/restore_decode_rule.class.php | 2 +- course/lib.php | 1 + enrol/imsenterprise/lib.php | 9 +++++++-- lib/simpletest/fixtures/gradetest.php | 1 + message/lib.php | 4 ++-- mod/lesson/format.php | 1 + mod/lesson/lib.php | 4 ++-- mod/lesson/pagetypes/essay.php | 2 ++ mod/quiz/lib.php | 1 + mod/survey/lib.php | 1 + question/behaviour/deferredcbm/renderer.php | 1 + question/engine/questionusage.php | 2 +- question/format/blackboard_six/format.php | 2 +- question/type/randomsamatch/questiontype.php | 2 ++ webservice/simpletest/testwebservice.php | 3 ++- 16 files changed, 27 insertions(+), 10 deletions(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index 654a87fffa7..6eba7761df6 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -461,6 +461,7 @@ } //Now build the EVENT record structure + $eve = new stdClass(); $eve->name = backup_todb($info['EVENT']['#']['NAME']['0']['#']); $eve->description = backup_todb($info['EVENT']['#']['DESCRIPTION']['0']['#']); $eve->format = backup_todb($info['EVENT']['#']['FORMAT']['0']['#']); diff --git a/backup/util/helper/restore_decode_rule.class.php b/backup/util/helper/restore_decode_rule.class.php index 52e6f63eeea..ded4126b3df 100644 --- a/backup/util/helper/restore_decode_rule.class.php +++ b/backup/util/helper/restore_decode_rule.class.php @@ -151,7 +151,7 @@ class restore_decode_rule { $countma = count($mappings); // Check mappings number matches placeholders if ($countph != $countma) { - $msg = new stdclass(); + $a = new stdClass(); $a->placeholders = $countph; $a->mappings = $countma; throw new restore_decode_rule_exception('decode_rule_mappings_incorrect_count', $a); diff --git a/course/lib.php b/course/lib.php index eae0beefbe1..e468fe76015 100644 --- a/course/lib.php +++ b/course/lib.php @@ -150,6 +150,7 @@ function build_mnet_logs_array($hostid, $course, $user=0, $date=0, $order="l.tim $groupid = 0; $joins = array(); + $where = ''; $qry = "SELECT l.*, u.firstname, u.lastname, u.picture FROM {mnet_log} l diff --git a/enrol/imsenterprise/lib.php b/enrol/imsenterprise/lib.php index ace7435297f..284608a7267 100644 --- a/enrol/imsenterprise/lib.php +++ b/enrol/imsenterprise/lib.php @@ -590,6 +590,8 @@ function process_membership_tag($tagcontents){ // In order to reduce the number of db queries required, group name/id associations are cached in this array: $groupids = array(); + $ship = new stdClass(); + if(preg_match('{.*?(.+?).*?}is', $tagcontents, $matches)){ $ship->coursecode = ($truncatecoursecodes > 0) ? substr(trim($matches[1]), 0, intval($truncatecoursecodes)) @@ -601,8 +603,8 @@ function process_membership_tag($tagcontents){ $courseobj->id = $ship->courseid; foreach($membermatches as $mmatch){ - unset($member); - unset($memberstoreobj); + $member = new stdClass(); + $memberstoreobj = new stdClass(); if(preg_match('{.*?(.+?).*?}is', $mmatch[1], $matches)){ $member->idnumber = trim($matches[1]); } @@ -622,6 +624,7 @@ function process_membership_tag($tagcontents){ //echo "

process_membership_tag: unenrolling member due to recstatus of 3

"; } + $timeframe = new stdClass(); $timeframe->begin = 0; $timeframe->end = 0; if(preg_match('{(.+?).*?}is', $mmatch[1], $matches)){ @@ -680,6 +683,7 @@ function process_membership_tag($tagcontents){ $groupids[$member->groupname] = $groupid; // Store ID in cache } else { // Attempt to create the group + $group = new stdClass(); $group->name = $member->groupname; $group->courseid = $ship->courseid; $group->timecreated = time(); @@ -752,6 +756,7 @@ function log_line($string){ * Process the INNER contents of a tag, to return beginning/ending dates. */ function decode_timeframe($string){ // Pass me the INNER CONTENTS of a tag - beginning and/or ending is returned, in unix time, zero indicating not specified + $ret = new stdClass(); $ret->begin = $ret->end = 0; // Explanatory note: The matching will ONLY match if the attribute restrict="1" // because otherwise the time markers should be ignored (participation should be diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index ea5f4a3c51e..614682cf292 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -291,6 +291,7 @@ class grade_test extends UnitTestCaseUsingDatabase { global $DB; $course_module = new stdClass(); $course_module->course = $this->courseid; + $quiz = new stdClass(); $quiz->module = 1; $quiz->instance = 2; $course_module->id = $DB->insert_record('course_modules', $course_module); diff --git a/message/lib.php b/message/lib.php index 9026b23b3ea..023b9948e3d 100644 --- a/message/lib.php +++ b/message/lib.php @@ -948,7 +948,7 @@ function message_add_contact($contactid, $blocked=0) { } else { /// new contact record - unset($contact); + $contact = new stdClass(); $contact->userid = $USER->id; $contact->contactid = $contactid; $contact->blocked = $blocked; @@ -1648,7 +1648,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none' /// The keys may be duplicated in $m_read and $m_unread so we can't /// do a simple concatenation - $message = array(); + $messages = array(); foreach ($m_read as $m) { $messages[] = $m; } diff --git a/mod/lesson/format.php b/mod/lesson/format.php index 11fbd4a9117..574bee16bbc 100644 --- a/mod/lesson/format.php +++ b/mod/lesson/format.php @@ -158,6 +158,7 @@ function lesson_save_question_options($question, $lesson) { case LESSON_PAGE_TRUEFALSE: // the truth + $answer = new stdClass(); $answer->lessonid = $question->lessonid; $answer->pageid = $question->id; $answer->timecreated = $timenow; diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index 3b515e82f79..6ca0738dfe3 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -171,9 +171,9 @@ function lesson_user_outline($course, $user, $mod, $lesson) { //if grade was last modified by the user themselves use date graded. Otherwise use date submitted //TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704 if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) { - $result->time = $grade->dategraded; + $return->time = $grade->dategraded; } else { - $result->time = $grade->datesubmitted; + $return->time = $grade->datesubmitted; } } return $return; diff --git a/mod/lesson/pagetypes/essay.php b/mod/lesson/pagetypes/essay.php index 148fe8eb4a7..d6705f34a5b 100644 --- a/mod/lesson/pagetypes/essay.php +++ b/mod/lesson/pagetypes/essay.php @@ -166,6 +166,7 @@ class lesson_page_type_essay extends lesson_page { $essaystats->total++; $pagestats[$temp->pageid] = $essaystats; } else { + $essaystats = new stdClass(); $essaystats->totalscore = $essayinfo->score; $essaystats->total = 1; $pagestats[$temp->pageid] = $essaystats; @@ -207,6 +208,7 @@ class lesson_page_type_essay extends lesson_page { $answerdata->score = get_string("havenotgradedyet", "lesson"); } } else { + $essayinfo = new stdClass(); $essayinfo->answer = get_string("didnotanswerquestion", "lesson"); } diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index dc24934a46a..5a0dddcc6fc 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -1444,6 +1444,7 @@ function quiz_num_attempt_summary($quiz, $cm, $returnzero = false, $currentgroup $numattempts = $DB->count_records('quiz_attempts', array('quiz'=> $quiz->id, 'preview'=>0)); if ($numattempts || $returnzero) { if (groups_get_activity_groupmode($cm)) { + $a = new stdClass(); $a->total = $numattempts; if ($currentgroup) { $a->group = $DB->count_records_sql('SELECT COUNT(DISTINCT qa.id) FROM ' . diff --git a/mod/survey/lib.php b/mod/survey/lib.php index 15e5483e626..3af83e42cfb 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -511,6 +511,7 @@ function survey_get_template_name($templateid) { */ function survey_shorten_name ($name, $numwords) { $words = explode(" ", $name); + $output = ''; for ($i=0; $i < $numwords; $i++) { $output .= $words[$i]." "; } diff --git a/question/behaviour/deferredcbm/renderer.php b/question/behaviour/deferredcbm/renderer.php index 45a9d06befa..8cb33d42ca4 100644 --- a/question/behaviour/deferredcbm/renderer.php +++ b/question/behaviour/deferredcbm/renderer.php @@ -88,6 +88,7 @@ class qbehaviour_deferredcbm_renderer extends qbehaviour_renderer { } if ($options->marks >= question_display_options::MARK_AND_MAX) { + $a = new stdClass(); $a->rawmark = format_float($qa->get_last_behaviour_var('_rawfraction') * $qa->get_max_mark(), $options->markdp); $a->mark = $qa->format_mark($options->markdp); diff --git a/question/engine/questionusage.php b/question/engine/questionusage.php index 7267fbb2fc8..6548bff073d 100644 --- a/question/engine/questionusage.php +++ b/question/engine/questionusage.php @@ -354,7 +354,7 @@ class question_usage_by_activity { * @return string HTML fragment. */ public function render_question_head_html($slot) { - $options->context = $this->context; + //$options->context = $this->context; return $this->get_question_attempt($slot)->render_head_html(); } diff --git a/question/format/blackboard_six/format.php b/question/format/blackboard_six/format.php index 44216b7fadf..484a31d24ff 100644 --- a/question/format/blackboard_six/format.php +++ b/question/format/blackboard_six/format.php @@ -507,7 +507,7 @@ function process_responses($bb_responses, &$responses) { //Added this line to instantiate $response. // Without instantiating the $response variable, the same object // gets added to the array - $response = null; + $response = new stdClass(); if (isset($bb_response['@']['title'])) { $response->title = $bb_response['@']['title']; } diff --git a/question/type/randomsamatch/questiontype.php b/question/type/randomsamatch/questiontype.php index 74e1dcbc923..a9641035c9e 100644 --- a/question/type/randomsamatch/questiontype.php +++ b/question/type/randomsamatch/questiontype.php @@ -62,10 +62,12 @@ class qtype_randomsamatch extends question_type { public function save_question_options($question) { global $DB; + $options = new stdClass(); $options->question = $question->id; $options->choose = $question->choose; if (2 > $question->choose) { + $result = new stdClass(); $result->error = "At least two shortanswer questions need to be chosen!"; return $result; } diff --git a/webservice/simpletest/testwebservice.php b/webservice/simpletest/testwebservice.php index 1b4e3e895e6..3bf0e86b1da 100644 --- a/webservice/simpletest/testwebservice.php +++ b/webservice/simpletest/testwebservice.php @@ -866,8 +866,9 @@ class webservice_test extends UnitTestCase { // custom fields if(!empty($user1->customfields)) { + $customuser1 = new stdClass(); + $customuser1->id = $user1->id; foreach($user1->customfields as $customfield) { - $customuser1->id = $user1->id; $customuser1->{"profile_field_".$customfield['type']} = $customfield['value']; } profile_save_data((object) $customuser1);