diff --git a/admin/blocks.php b/admin/blocks.php index 55170d28dfa..15c30e64ee7 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -126,6 +126,7 @@ // Remove event handlers and dequeue pending events events_uninstall('block/'.$block->name); + $a = new stdClass(); $a->block = $strblockname; $a->directory = $CFG->dirroot.'/blocks/'.$block->name; notice(get_string('blockdeletefiles', '', $a), 'blocks.php'); diff --git a/admin/enrol.php b/admin/enrol.php index 26e430ef8f7..8e46e24367d 100644 --- a/admin/enrol.php +++ b/admin/enrol.php @@ -31,6 +31,7 @@ $enrol = required_param('enrol', PARAM_SAFEDIR); $confirm = optional_param('confirm', 0, PARAM_BOOL); $PAGE->set_url('/admin/enrol.php'); +$PAGE->set_context(context_system::instance()); require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); @@ -107,6 +108,7 @@ switch ($action) { } else { // Delete everything!! uninstall_plugin('enrol', $enrol); + $a = new stdClass(); $a->plugin = $strplugin; $a->directory = "$CFG->dirroot/enrol/$enrol"; echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess'); diff --git a/admin/modules.php b/admin/modules.php index 71e22bdb488..da20d9ad46b 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -92,6 +92,7 @@ } uninstall_plugin('mod', $delete); + $a = new stdClass(); $a->module = $strmodulename; $a->directory = "$CFG->dirroot/mod/$delete"; echo $OUTPUT->notification(get_string("moduledeletefiles", "", $a), 'notifysuccess'); diff --git a/admin/qbehaviours.php b/admin/qbehaviours.php index be8cc4a67ce..507b9136ddb 100644 --- a/admin/qbehaviours.php +++ b/admin/qbehaviours.php @@ -194,6 +194,7 @@ if (($delete = optional_param('delete', '', PARAM_SAFEDIR)) && confirm_sesskey() // Remove event handlers and dequeue pending events events_uninstall('qbehaviour_' . $delete); + $a = new stdClass(); $a->behaviour = $behaviourname; $a->directory = get_plugin_directory('qbehaviour', $delete); echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice'); diff --git a/admin/qtypes.php b/admin/qtypes.php index a95de209099..fcae6cf4856 100644 --- a/admin/qtypes.php +++ b/admin/qtypes.php @@ -173,6 +173,7 @@ if (($delete = optional_param('delete', '', PARAM_SAFEDIR)) && confirm_sesskey() // Remove event handlers and dequeue pending events events_uninstall('qtype_' . $delete); + $a = new stdClass(); $a->qtype = $qtypename; $a->directory = $qtypes[$delete]->plugin_dir(); echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice'); diff --git a/admin/timezoneimport.php b/admin/timezoneimport.php index a09f17d5330..f149f07f808 100644 --- a/admin/timezoneimport.php +++ b/admin/timezoneimport.php @@ -89,7 +89,7 @@ /// That's it! if ($importdone) { - $a = null; + $a = new stdClass(); $a->count = count($timezones); $a->source = $importdone; echo $OUTPUT->heading(get_string('importtimezonescount', 'admin', $a), 3); diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php index 856b9b83442..331f353b86f 100644 --- a/blocks/admin_bookmarks/block_admin_bookmarks.php +++ b/blocks/admin_bookmarks/block_admin_bookmarks.php @@ -79,6 +79,7 @@ class block_admin_bookmarks extends block_base { if ($this->contentgenerated === true) { return $this->content; } + $this->content = new stdClass(); if (get_user_preferences('admin_bookmarks')) { require_once($CFG->libdir.'/adminlib.php'); diff --git a/blocks/comments/block_comments.php b/blocks/comments/block_comments.php index a00cd09edfc..527d02037c3 100644 --- a/blocks/comments/block_comments.php +++ b/blocks/comments/block_comments.php @@ -48,21 +48,23 @@ class block_comments extends block_base { function get_content() { global $CFG, $PAGE; + if ($this->content !== NULL) { + return $this->content; + } if (!$CFG->usecomments) { + $this->content = new stdClass(); $this->content->text = ''; if ($this->page->user_is_editing()) { $this->content->text = get_string('disabledcomments'); } return $this->content; } - if ($this->content !== NULL) { - return $this->content; - } - if (empty($this->instance)) { - return null; - } + $this->content = new stdClass(); $this->content->footer = ''; $this->content->text = ''; + if (empty($this->instance)) { + return $this->content; + } list($context, $course, $cm) = get_context_info_array($PAGE->context->id); $args = new stdClass; diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php index 72fc75bcffe..649cd77a9a8 100644 --- a/blocks/glossary_random/block_glossary_random.php +++ b/blocks/glossary_random/block_glossary_random.php @@ -119,6 +119,7 @@ class block_glossary_random extends block_base { global $USER, $CFG, $DB; if (empty($this->config->glossary)) { + $this->content = new stdClass(); $this->content->text = get_string('notyetconfigured','block_glossary_random'); $this->content->footer = ''; return $this->content; @@ -153,7 +154,7 @@ class block_glossary_random extends block_base { return $this->content; } - $this->content = new stdClass; + $this->content = new stdClass(); $this->content->text = $this->config->cache; // place link to glossary in the footer if the glossary is visible diff --git a/blocks/html/edit_form.php b/blocks/html/edit_form.php index 30c005dcaec..aa7b4661de8 100644 --- a/blocks/html/edit_form.php +++ b/blocks/html/edit_form.php @@ -72,6 +72,9 @@ class block_html_edit_form extends block_edit_form { unset($this->block->config->text); parent::set_data($defaults); // restore $text + if (!isset($this->block->config)) { + $this->block->config = new stdClass(); + } $this->block->config->text = $text; if (isset($title)) { // Reset the preserved title diff --git a/blocks/login/block_login.php b/blocks/login/block_login.php index 30d373a0653..431d31a2412 100644 --- a/blocks/login/block_login.php +++ b/blocks/login/block_login.php @@ -43,6 +43,7 @@ class block_login extends block_base { $username = get_moodle_cookie(); + $this->content = new stdClass(); $this->content->footer = ''; $this->content->text = ''; diff --git a/blocks/mentees/block_mentees.php b/blocks/mentees/block_mentees.php index 45d9463cf7b..aa340af7e41 100644 --- a/blocks/mentees/block_mentees.php +++ b/blocks/mentees/block_mentees.php @@ -25,6 +25,8 @@ class block_mentees extends block_base { return $this->content; } + $this->content = new stdClass(); + // get all the mentees, i.e. users you have a direct assignment to if ($usercontexts = $DB->get_records_sql("SELECT c.instanceid, c.instanceid, u.firstname, u.lastname FROM {role_assignments} ra, {context} c, {user} u diff --git a/blocks/navigation/block_navigation.php b/blocks/navigation/block_navigation.php index 77cc00a3a82..3f47030ad61 100644 --- a/blocks/navigation/block_navigation.php +++ b/blocks/navigation/block_navigation.php @@ -195,6 +195,7 @@ class block_navigation extends block_base { // Grab the items to display $renderer = $this->page->get_renderer('block_navigation'); + $this->content = new stdClass(); $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options); // Set content generated to true so that we know it has been done diff --git a/blocks/private_files/block_private_files.php b/blocks/private_files/block_private_files.php index a552dd91423..32e1282e5b3 100644 --- a/blocks/private_files/block_private_files.php +++ b/blocks/private_files/block_private_files.php @@ -51,6 +51,7 @@ class block_private_files extends block_base { return null; } + $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; if (isloggedin() && !isguestuser()) { // Show the block diff --git a/blocks/settings/block_settings.php b/blocks/settings/block_settings.php index 89706f670dd..3e2aea838e3 100644 --- a/blocks/settings/block_settings.php +++ b/blocks/settings/block_settings.php @@ -129,6 +129,7 @@ class block_settings extends block_base { } $renderer = $this->page->get_renderer('block_settings'); + $this->content = new stdClass(); $this->content->text = $renderer->settings_tree($this->page->settingsnav); // only do search if you have moodle/site:config diff --git a/blocks/tags/block_tags.php b/blocks/tags/block_tags.php index 0a35df176e4..b7a35fd9bab 100644 --- a/blocks/tags/block_tags.php +++ b/blocks/tags/block_tags.php @@ -47,6 +47,10 @@ class block_tags extends block_base { return $this->content; } + if (!isset($this->config)) { + $this->config = new stdClass(); + } + if (empty($this->config->numberoftags)) { $this->config->numberoftags = 80; } diff --git a/calendar/lib.php b/calendar/lib.php index c60e6b63e35..8b9e480f9b0 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1540,6 +1540,7 @@ function calendar_set_event_type_display($type, $display = null, $user = null) { function calendar_get_allowed_types(&$allowed, $course = null) { global $USER, $CFG, $DB; + $allowed = new stdClass(); $allowed->user = has_capability('moodle/calendar:manageownentries', get_system_context()); $allowed->groups = false; // This may change just below $allowed->courses = false; // This may change just below diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index 74fb96427f6..c5c78faf139 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -141,7 +141,7 @@ defined('MOODLE_INTERNAL') || die(); $thissection = $sections[$section]; } else { - unset($thissection); + $thissection = new stdClass(); $thissection->course = $course->id; // Create a new week structure $thissection->section = $section; $thissection->name = null; diff --git a/course/index.php b/course/index.php index f0a0c104893..e87312848e2 100644 --- a/course/index.php +++ b/course/index.php @@ -373,6 +373,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $ echo ''; echo ''; } else { + $category = new stdClass(); $category->id = '0'; } diff --git a/course/lib.php b/course/lib.php index ecfa79f4c29..ecefb941fca 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1086,6 +1086,7 @@ function get_array_of_activities($courseid) { if (empty($rawmods[$seq])) { continue; } + $mod[$seq] = new stdClass(); $mod[$seq]->id = $rawmods[$seq]->instance; $mod[$seq]->cm = $rawmods[$seq]->id; $mod[$seq]->mod = $rawmods[$seq]->modname; @@ -2111,6 +2112,7 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli } } else { + $category = new stdClass(); $category->id = "0"; } @@ -2478,7 +2480,7 @@ function print_course($course, $highlightterms = '') { echo html_writer::end_tag('div'); // End of info div echo html_writer::start_tag('div', array('class'=>'summary')); - $options = NULL; + $options = new stdClass(); $options->noclean = true; $options->para = false; $options->overflowdiv = true; @@ -2625,7 +2627,7 @@ function print_remote_course($course, $width="100%") { . format_string($course->cat_name) . ' : ' . format_string($course->shortname). ''; echo '
'; - $options = NULL; + $options = new stdClass(); $options->noclean = true; $options->para = false; $options->overflowdiv = true; diff --git a/lib/blocklib.php b/lib/blocklib.php index 0980b0ad6f9..03053d77e78 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1676,7 +1676,7 @@ function generate_page_type_patterns($pagetype, $parentcontext = null, $currentc // Ensure that the * pattern is always available if editing block 'at distance', so // we always can 'bring back' it to the original context. MDL-30340 - if ($currentcontext->id != $parentcontext->id && !isset($patterns['*'])) { + if ((!isset($currentcontext) or !isset($parentcontext) or $currentcontext->id != $parentcontext->id) && !isset($patterns['*'])) { // TODO: We could change the string here, showing its 'bring back' meaning $patterns['*'] = get_string('page-x', 'pagetype'); } diff --git a/lib/datalib.php b/lib/datalib.php index e508d75766d..0280c343a53 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1232,7 +1232,7 @@ function get_my_remotehosts() { function make_default_scale() { global $DB; - $defaultscale = NULL; + $defaultscale = new stdClass(); $defaultscale->courseid = 0; $defaultscale->userid = 0; $defaultscale->name = get_string('separateandconnected'); diff --git a/lib/filelib.php b/lib/filelib.php index 67ffe13c21c..5b1e07e5476 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -128,6 +128,9 @@ function file_prepare_standard_editor($data, $field, array $options, $context=nu if (is_null($itemid) or is_null($context)) { $contextid = null; $itemid = null; + if (!isset($data)) { + $data = new stdClass(); + } if (!isset($data->{$field})) { $data->{$field} = ''; } diff --git a/lib/formslib.php b/lib/formslib.php index d36a846605c..29ff0129a3b 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -2441,6 +2441,10 @@ class MoodleQuickForm_Rule_Required extends HTML_QuickForm_Rule { if (is_array($value) && array_key_exists('text', $value)) { $value = $value['text']; } + if (is_array($value)) { + // nasty guess - there has to be something in the array, hopefully nobody invents arrays in arrays + $value = implode('', $value); + } $stripvalues = array( '##im', // all tags except img, canvas and hr '#(\xc2|\xa0|\s| )#', //any whitespaces actually diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 3ecb5fa9037..cd4480fc88a 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1076,7 +1076,7 @@ function get_config($plugin, $name = NULL) { if ($localcfg) { return (object)$localcfg; } else { - return null; + return new stdClass(); } } else { @@ -1626,6 +1626,7 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0, $totalsecs = abs($totalsecs); if (!$str) { // Create the str structure the slow way + $str = new stdClass(); $str->day = get_string('day'); $str->days = get_string('days'); $str->hour = get_string('hour'); diff --git a/login/index.php b/login/index.php index 00616f3265b..ebe08f06264 100644 --- a/login/index.php +++ b/login/index.php @@ -285,6 +285,10 @@ $PAGE->verify_https_required(); /// Generate the login page with forms +if (!isset($frm) or !is_object($frm)) { + $frm = new stdClass(); +} + if (empty($frm->username) && $authsequence[0] != 'shibboleth') { // See bug 5184 if (!empty($_GET["username"])) { $frm->username = $_GET["username"]; diff --git a/message/lib.php b/message/lib.php index b86f456c03b..1e0fad0f0c1 100644 --- a/message/lib.php +++ b/message/lib.php @@ -1342,6 +1342,7 @@ function message_contact_link($userid, $linktype='add', $return=false, $script=n } if (empty($str->blockcontact)) { + $str = new stdClass(); $str->blockcontact = get_string('blockcontact', 'message'); $str->unblockcontact = get_string('unblockcontact', 'message'); $str->removecontact = get_string('removecontact', 'message'); diff --git a/mod/chat/lib.php b/mod/chat/lib.php index a462b6e2d65..4354e4d5548 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -112,7 +112,7 @@ function chat_add_instance($chat) { $returnid = $DB->insert_record("chat", $chat); - $event = NULL; + $event = new stdClass(); $event->name = $chat->name; $event->description = format_module_intro('chat', $chat, $chat->coursemodule); $event->courseid = $chat->course; diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 40bd90f0396..8795de24c48 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -654,8 +654,8 @@ function feedback_set_events($feedback) { } // the open-event - if($feedback->timeopen > 0) { - $event = NULL; + if ($feedback->timeopen > 0) { + $event = new stdClass(); $event->name = get_string('start', 'feedback').' '.$feedback->name; $event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule); $event->courseid = $feedback->course; @@ -676,8 +676,8 @@ function feedback_set_events($feedback) { } // the close-event - if($feedback->timeclose > 0) { - $event = NULL; + if ($feedback->timeclose > 0) { + $event = new stdClass(); $event->name = get_string('stop', 'feedback').' '.$feedback->name; $event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule); $event->courseid = $feedback->course; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 2129110e09c..b4dbdb7eade 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2918,6 +2918,7 @@ function forum_get_course_forum($courseid, $type) { } // Doesn't exist, so create one now. + $forum = new stdClass(); $forum->course = $courseid; $forum->type = "$type"; switch ($forum->type) { diff --git a/mod/forum/post.php b/mod/forum/post.php index f3f2f8219bf..f3fd922de4a 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -792,6 +792,7 @@ if ($post->discussion) { print_error('cannotfindparentpost', 'forum', '', $post->id); } } else { + $toppost = new stdClass(); $toppost->subject = ($forum->type == "news") ? get_string("addanewtopic", "forum") : get_string("addanewdiscussion", "forum"); } diff --git a/user/index.php b/user/index.php index 31ccbeefd9d..fbba7f3beb5 100644 --- a/user/index.php +++ b/user/index.php @@ -103,6 +103,7 @@ $strnever = get_string('never'); + $datestring = new stdClass(); $datestring->year = get_string('year'); $datestring->years = get_string('years'); $datestring->day = get_string('day'); @@ -468,6 +469,7 @@ } if ($roleid > 0) { + $a = new stdClass(); $a->number = $totalcount; $a->role = $rolenames[$roleid]; $heading = format_string(get_string('xuserswiththerole', 'role', $a)); @@ -483,6 +485,7 @@ } $heading .= ": $a->number"; + if (user_can_assign($context, $roleid)) { $heading .= ' '; $heading .= '';