MDL-31006 some more PHP54 notices
authorPetr Skoda <commits@skodak.org>
Sun, 15 Jan 2012 20:49:30 +0000 (21:49 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 18 Jan 2012 00:17:25 +0000 (01:17 +0100)
PHP54 compatibility - PhpStorm IDE is the best tool for this kind of work!!

16 files changed:
backup/restorelib.php
backup/util/helper/restore_decode_rule.class.php
course/lib.php
enrol/imsenterprise/lib.php
lib/simpletest/fixtures/gradetest.php
message/lib.php
mod/lesson/format.php
mod/lesson/lib.php
mod/lesson/pagetypes/essay.php
mod/quiz/lib.php
mod/survey/lib.php
question/behaviour/deferredcbm/renderer.php
question/engine/questionusage.php
question/format/blackboard_six/format.php
question/type/randomsamatch/questiontype.php
webservice/simpletest/testwebservice.php

index 654a87f..6eba776 100644 (file)
                         }
 
                         //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']['#']);
index 52e6f63..ded4126 100644 (file)
@@ -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);
index eae0bee..e468fe7 100644 (file)
@@ -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
index ace7435..284608a 100644 (file)
@@ -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('{<sourcedid>.*?<id>(.+?)</id>.*?</sourcedid>}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('{<sourcedid>.*?<id>(.+?)</id>.*?</sourcedid>}is', $mmatch[1], $matches)){
                 $member->idnumber = trim($matches[1]);
             }
@@ -622,6 +624,7 @@ function process_membership_tag($tagcontents){
               //echo "<p>process_membership_tag: unenrolling member due to recstatus of 3</p>";
             }
 
+            $timeframe = new stdClass();
             $timeframe->begin = 0;
             $timeframe->end = 0;
             if(preg_match('{<role\b.*?<timeframe>(.+?)</timeframe>.*?</role>}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 <timeframe> tag, to return beginning/ending dates.
 */
 function decode_timeframe($string){ // Pass me the INNER CONTENTS of a <timeframe> 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
index ea5f4a3..614682c 100644 (file)
@@ -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);
index 9026b23..023b994 100644 (file)
@@ -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;
     }
index 11fbd4a..574bee1 100644 (file)
@@ -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;
index 3b515e8..6ca0738 100644 (file)
@@ -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;
index 148fe8e..d6705f3 100644 (file)
@@ -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");
             }
 
index dc24934..5a0dddc 100644 (file)
@@ -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 ' .
index 15e5483..3af83e4 100644 (file)
@@ -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]." ";
     }
index 45a9d06..8cb33d4 100644 (file)
@@ -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);
index 7267fbb..6548bff 100644 (file)
@@ -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();
     }
 
index 44216b7..484a31d 100644 (file)
@@ -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'];
             }
index 74e1dcb..a964103 100644 (file)
@@ -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;
         }
index 1b4e3e8..3bf0e86 100644 (file)
@@ -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);