Skip to content

Commit

Permalink
MDL-31006 fix various notices in PHP54
Browse files Browse the repository at this point in the history
PHP54 compatibility
  • Loading branch information
skodak authored and stronk7 committed Jan 18, 2012
1 parent ae92487 commit b85b25e
Show file tree
Hide file tree
Showing 34 changed files with 71 additions and 17 deletions.
1 change: 1 addition & 0 deletions admin/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
} else {
uninstall_plugin('block', $block->name);

$a = new stdClass();
$a->block = $strblockname;
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
notice(get_string('blockdeletefiles', '', $a), 'blocks.php');
Expand Down
2 changes: 2 additions & 0 deletions admin/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$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));
Expand Down Expand Up @@ -112,6 +113,7 @@
uninstall_plugin('enrol', $enrol);
$syscontext->mark_dirty(); // resets all enrol caches

$a = new stdClass();
$a->plugin = $strplugin;
$a->directory = "$CFG->dirroot/enrol/$enrol";
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
Expand Down
1 change: 1 addition & 0 deletions admin/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions admin/qbehaviours.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
// 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');
Expand Down
1 change: 1 addition & 0 deletions admin/qtypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
// 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');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/timezoneimport/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
/// That's it!

if ($importdone) {
$a = null;
$a = new stdClass();
$a->count = count($timezones);
$a->source = $importdone;
echo $OUTPUT->heading(get_string('importtimezonescount', 'tool_timezoneimport', $a), 3);
Expand Down
1 change: 1 addition & 0 deletions blocks/admin_bookmarks/block_admin_bookmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function get_content() {
if ($this->contentgenerated === true) {
return $this->content;
}
$this->content = new stdClass();

if (get_user_preferences('admin_bookmarks')) {
require_once($CFG->libdir.'/adminlib.php');
Expand Down
14 changes: 8 additions & 6 deletions blocks/comments/block_comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ function instance_allow_multiple() {

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;
Expand Down
3 changes: 2 additions & 1 deletion blocks/glossary_random/block_glossary_random.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function get_content() {
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;
Expand Down Expand Up @@ -153,7 +154,7 @@ function get_content() {
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
Expand Down
3 changes: 3 additions & 0 deletions blocks/html/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ function set_data($defaults) {
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
Expand Down
1 change: 1 addition & 0 deletions blocks/login/block_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function get_content () {

$username = get_moodle_cookie();

$this->content = new stdClass();
$this->content->footer = '';
$this->content->text = '';

Expand Down
2 changes: 2 additions & 0 deletions blocks/mentees/block_mentees.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function get_content() {
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
Expand Down
1 change: 1 addition & 0 deletions blocks/navigation/block_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function get_content() {

// 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
Expand Down
1 change: 1 addition & 0 deletions blocks/private_files/block_private_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function get_content() {
return null;
}

$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (isloggedin() && !isguestuser()) { // Show the block
Expand Down
1 change: 1 addition & 0 deletions blocks/settings/block_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function get_content() {
}

$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
Expand Down
4 changes: 4 additions & 0 deletions blocks/tags/block_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function get_content() {
return $this->content;
}

if (!isset($this->config)) {
$this->config = new stdClass();
}

if (empty($this->config->numberoftags)) {
$this->config->numberoftags = 80;
}
Expand Down
1 change: 1 addition & 0 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion course/format/weeks/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
$thissection = $sections[$section];

} else {
unset($thissection);
$thissection = new stdClass();
$thissection->course = $course->id; // Create a new week structure
$thissection->section = $section;
$thissection->name = null;
Expand Down
1 change: 1 addition & 0 deletions course/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
echo '</td>';
echo '</tr>';
} else {
$category = new stdClass();
$category->id = '0';
}

Expand Down
6 changes: 4 additions & 2 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,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;
Expand Down Expand Up @@ -2127,6 +2128,7 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli
}

} else {
$category = new stdClass();
$category->id = "0";
}

Expand Down Expand Up @@ -2500,7 +2502,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;
Expand Down Expand Up @@ -2647,7 +2649,7 @@ function print_remote_course($course, $width="100%") {
. format_string($course->cat_name) . ' : '
. format_string($course->shortname). '</div>';
echo '</div><div class="summary">';
$options = NULL;
$options = new stdClass();
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,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');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,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');
Expand Down
3 changes: 3 additions & 0 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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} = '';
}
Expand Down
8 changes: 8 additions & 0 deletions lib/filterlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,10 @@ function filter_get_all_local_settings($contextid) {
function filter_get_active_in_context($context) {
global $DB, $FILTERLIB_PRIVATE;

if (!isset($FILTERLIB_PRIVATE)) {
$FILTERLIB_PRIVATE = new stdClass();
}

// Use cache (this is a within-request cache only) if available. See
// function filter_preload_activities.
if (isset($FILTERLIB_PRIVATE->active) &&
Expand Down Expand Up @@ -877,6 +881,10 @@ function filter_get_active_in_context($context) {
function filter_preload_activities(course_modinfo $modinfo) {
global $DB, $FILTERLIB_PRIVATE;

if (!isset($FILTERLIB_PRIVATE)) {
$FILTERLIB_PRIVATE = new stdClass();
}

// Don't repeat preload
if (!isset($FILTERLIB_PRIVATE->preloaded)) {
$FILTERLIB_PRIVATE->preloaded = array();
Expand Down
4 changes: 4 additions & 0 deletions lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2466,6 +2466,10 @@ function validate($value, $options = null) {
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(
'#</?(?!img|canvas|hr).*?>#im', // all tags except img, canvas and hr
'#(\xc2|\xa0|\s|&nbsp;)#', //any whitespaces actually
Expand Down
3 changes: 2 additions & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ function get_config($plugin, $name = NULL) {
if ($localcfg) {
return (object)$localcfg;
} else {
return null;
return new stdClass();
}

} else {
Expand Down Expand Up @@ -1869,6 +1869,7 @@ function format_time($totalsecs, $str=NULL) {
$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');
Expand Down
4 changes: 4 additions & 0 deletions login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@

/// 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 = clean_param($_GET["username"], PARAM_RAW); // we do not want data from _POST here
Expand Down
1 change: 1 addition & 0 deletions message/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,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');
Expand Down
2 changes: 1 addition & 1 deletion mod/chat/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions mod/feedback/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ function feedback_set_events($feedback) {

// the open-event
if ($feedback->timeopen > 0) {
$event = null;
$event = new stdClass();
$event->name = get_string('start', 'feedback').' '.$feedback->name;
$event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule);
$event->courseid = $feedback->course;
Expand All @@ -731,7 +731,7 @@ function feedback_set_events($feedback) {

// the close-event
if ($feedback->timeclose > 0) {
$event = null;
$event = new stdClass();
$event->name = get_string('stop', 'feedback').' '.$feedback->name;
$event->description = format_module_intro('feedback', $feedback, $feedback->coursemodule);
$event->courseid = $feedback->course;
Expand Down
1 change: 1 addition & 0 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2921,6 +2921,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) {
Expand Down
1 change: 1 addition & 0 deletions mod/forum/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@
print_error('cannotfindparentpost', 'forum', '', $post->id);
}
} else {
$toppost = new stdClass();
$toppost->subject = ($forum->type == "news") ? get_string("addanewtopic", "forum") :
get_string("addanewdiscussion", "forum");
}
Expand Down
1 change: 1 addition & 0 deletions report/participation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@

$data = array();

$a = new stdClass();
$a->count = $totalcount;
$a->items = $role->name;

Expand Down
Loading

0 comments on commit b85b25e

Please sign in to comment.