Skip to content

Instantly share code, notes, and snippets.

View mudrd8mz's full-sized avatar

David Mudrák mudrd8mz

View GitHub Profile
diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php
index 7b705a91be..00bfdc2810 100644
--- a/lib/outputrenderers.php
+++ b/lib/outputrenderers.php
@@ -1833,6 +1833,13 @@ class core_renderer extends renderer_base {
if (empty($zones)) {
// There are no zones, probably because there are no blocks.
$regions = $this->page->theme->get_all_block_regions();
+ // Append the eventually injected custom regions.
+ foreach ($this->page->blocks->get_regions() as $regioninternalname) {
// ...
$done = 0;
foreach ($courses as $course) {
if ($options['skip-recycle-bin']) {
// This is a hack, we pretend to be executed by the restore process
// so that the recycle bin hook is skipped.
$course->deletesource = 'restore';
}
if (!delete_course($course, false)) {
throw new moodle_exception('cannotdeletecategorycourse', '', '', $course->shortname);
@mudrd8mz
mudrd8mz / mtrace-console-pid.patch
Created January 21, 2019 15:04
Moodle mtrace modification that makes PID appear in cron logs
commit xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Author: David Mudrák <david@moodle.com>
Date: Mon Jan 21 15:49:09 2019 +0100
Include PID in mtrace console output, e.g. in cron logs
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 18e7a74cef..8d45d8d84c 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@mudrd8mz
mudrd8mz / test-MDL-56800.php
Created November 29, 2016 08:48
Test script to demonstrate MDL-56800
<?php
require_once(__DIR__.'/config.php');
require_once($CFG->libdir . '/formslib.php');
class test_form extends moodleform {
public function definition() {
$mform = $this->_form;
$grp = [];
define(['core/yui'], function(Y) {
// ...
function foo() {
Y.use('core_filepicker', function (Y) {
// ...
M.core_filepicker.show(Y, options);
// ^^^ if executed quick enough, this fails with
// TypeError: Y.Node.createWithFilesSkin(...) is null
diff --git a/lib/tablelib.php b/lib/tablelib.php
index 06516e9..872ddc8 100644
--- a/lib/tablelib.php
+++ b/lib/tablelib.php
@@ -535,6 +535,9 @@ class flexible_table {
'i_last' => '',
'textsort' => $this->column_textsort,
);
+ if (!empty($this->sort_default_column)) {
+ $this->prefs['sortby'] = array($this->sort_default_column => $this->sort_default_order);
@mudrd8mz
mudrd8mz / lib.php.patch
Created December 10, 2013 15:41
Custom hack for moodle-mod_forum that causes f1.png avatar is used when displaying the post, instead of the default (smaller) f2.png
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 1966ec1..313bff9 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -3465,7 +3465,7 @@ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=fa
'aria-label' => $discussionbyuser));
$output .= html_writer::start_tag('div', array('class'=>'row header clearfix'));
$output .= html_writer::start_tag('div', array('class'=>'left picture'));
- $output .= $OUTPUT->user_picture($postuser, array('courseid'=>$course->id));
+ $output .= $OUTPUT->user_picture($postuser, array('courseid'=>$course->id, 'size' => 60));
<?php
// Put this file into the dirroot of your Moodle 2.6beta and execute it, e.g.
//
// $ sudo -u apache php bg_locale_test.php
//
// Please report results to David or at MDLSITE-2580
define('CLI_SCRIPT', 1);
var foo, bar,
baz, frog,
now = Date().getTime(),
doSomething = function (arg) {
var localVar;
},
Coding error detected, it must be fixed by a programmer: Trying to reference an unknown block region side-pre
Debug info:
Error code: codingerror
Stack trace:
line 889 of /lib/blocklib.php: coding_exception thrown
line 989 of /lib/blocklib.php: call to block_manager->check_region_is_known()
line 1002 of /lib/blocklib.php: call to block_manager->ensure_instances_exist()
line 315 of /lib/blocklib.php: call to block_manager->ensure_content_created()