From 586cf92909cbc1deb9216cdd53598a5401661572 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Thu, 6 Oct 2016 11:15:58 +0100 Subject: [PATCH] MDL-45388 admin: warn of themedesignermode in /admin/ and perf footer This is: a) To help avoid devs going on a wild goose chase to find a perf issue when it's caused by css building b) To make it clearer that this should never be enabled on production sites (we already have a warning in the performance report, but who looks at that) Now that boost is the default theme and builds css itself, it's more critical. --- admin/index.php | 3 ++- admin/renderer.php | 16 +++++++++++++++- lang/en/admin.php | 1 + lib/moodlelib.php | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/admin/index.php b/admin/index.php index 2cf9d1aa4d0..6f87285dea7 100644 --- a/admin/index.php +++ b/admin/index.php @@ -851,6 +851,7 @@ $registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOOD $cachewarnings = cache_helper::warnings(); // Check if there are events 1 API handlers. $eventshandlers = $DB->get_records_sql('SELECT DISTINCT component FROM {events_handlers}'); +$themedesignermode = !empty($CFG->themedesignermode); admin_externalpage_setup('adminnotifications'); @@ -858,4 +859,4 @@ $output = $PAGE->get_renderer('core', 'admin'); echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb, - $registered, $cachewarnings, $eventshandlers); + $registered, $cachewarnings, $eventshandlers, $themedesignermode); diff --git a/admin/renderer.php b/admin/renderer.php index 7895c316c6e..2b841d6acb7 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -281,7 +281,7 @@ class core_admin_renderer extends plugin_renderer_base { */ public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, - $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0) { + $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0, $themedesignermode = false) { global $CFG; $output = ''; @@ -290,6 +290,7 @@ class core_admin_renderer extends plugin_renderer_base { $output .= $this->legacy_log_store_writing_error(); $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : ''; $output .= $this->insecure_dataroot_warning($insecuredataroot); + $output .= $this->themedesignermode_warning($themedesignermode); $output .= $this->display_errors_warning($errorsdisplayed); $output .= $this->buggy_iconv_warning($buggyiconvnomb); $output .= $this->cron_overdue_warning($cronoverdue); @@ -532,6 +533,19 @@ class core_admin_renderer extends plugin_renderer_base { return $this->warning(get_string('displayerrorswarning', 'admin')); } + /** + * Render an appropriate message if themdesignermode is enabled. + * @param bool $themedesignermode true if enabled + * @return string HTML to output. + */ + protected function themedesignermode_warning($themedesignermode) { + if (!$themedesignermode) { + return ''; + } + + return $this->warning(get_string('themedesignermodewarning', 'admin')); + } + /** * Render an appropriate message if iconv is buggy and mbstring missing. * @param bool $buggyiconvnomb diff --git a/lang/en/admin.php b/lang/en/admin.php index 5071ec5d4fb..c8c1ed31893 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1065,6 +1065,7 @@ $string['tasktagcron'] = 'Background processing for tags'; $string['tasktempfilecleanup'] = 'Delete stale temp files'; $string['tempdatafoldercleanup'] = 'Clean up temporary data files older than'; $string['themedesignermode'] = 'Theme designer mode'; +$string['themedesignermodewarning'] = 'Theme designer mode is enabled. This should not be enabled on production sites as it can significantly reduce performance.'; $string['themelist'] = 'Theme list'; $string['themenoselected'] = 'No theme selected'; $string['themeresetcaches'] = 'Clear theme caches'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index cb08387dae6..26619f269ec 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -8955,6 +8955,11 @@ function get_performance_info() { $info['html'] = ''; // Holds userfriendly HTML representation. $info['txt'] = me() . ' '; // Holds log-friendly representation. + if (!empty($CFG->themedesignermode)) { + // Attempt to avoid devs debugging peformance issues, when its caused by css building and so on. + $info['html'] = '

Warning: Theme designer mode is enabled.

'; + } + $info['realtime'] = microtime_diff($PERF->starttime, microtime()); $info['html'] .= ''.$info['realtime'].' secs ';