Table of Contents
[Moodle Edash] Fix Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Err info
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated... theme/edash/renderers/course-renderer.php on line 53
Fix Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Origin Function
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth) {
global $CFG, $PAGE;
$categoryname = $coursecat->get_formatted_name();
$edash_category_link = new moodle_url('/course/index.php', array('categoryid' => $coursecat->id));
$edash_cat = $coursecat->id;
$edash_cat_summary_unclean = $chelper->get_category_formatted_description($coursecat);
$edash_cat_summary = preg_replace("/<img[^>]+\>/i", " ", $edash_cat_summary_unclean);
$children_courses = $coursecat->get_courses();
$edash_items_count = '';
if ($coursecat->get_children_count() > 0) {
$edash_items_count .= $coursecat->get_children_count() . ' ' . get_string('categories');
} else {
$edash_items_count .= count($coursecat->get_courses()) . ' ' . get_string('courses');
}
$edash_cat_updated = get_string('modified') . ' ' . userdate($coursecat->timemodified, '%d %B %Y', 0);
..............
Change $edash_cat_summary
from
$edash_cat_summary = preg_replace("/<img[^>]+\>/i", " ", $edash_cat_summary_unclean);
to
$edash_cat_summary = $edash_cat_summary_unclean ? preg_replace("/<img[^>]+\>/i", " ", $edash_cat_summary_unclean): "";