Skip to content

Instantly share code, notes, and snippets.

View mudrd8mz's full-sized avatar

David Mudrák mudrd8mz

View GitHub Profile
@mudrd8mz
mudrd8mz / gist:5508113
Created May 3, 2013 09:10
Proposal for format_text() check in Moodle
diff --git a/lib/weblib.php b/lib/weblib.php
index 647504a..28aef68 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -1174,6 +1174,14 @@ function format_text($text, $format = FORMAT_MOODLE, $options = NULL, $courseid_
// The only potential problem is that somebody might try to format
// the text before storing into database which would be itself big bug.
$text = str_replace("\"$CFG->httpswwwroot/draftfile.php", "\"$CFG->httpswwwroot/brokenfile.php#", $text);
+
+ // Before calling format_text(), the text must be processed with {@link file_rewrite_pluginfile_urls()}
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()
var foo, bar,
baz, frog,
now = Date().getTime(),
doSomething = function (arg) {
var localVar;
},
<?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);
@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));
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);
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
@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 = [];
@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 <[email protected]>
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
// ...
$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);