Skip to content

Commit

Permalink
MDL-44977 tool_profiling: set xhprof default settings
Browse files Browse the repository at this point in the history
Set xhprof default settings, even if xhprof is not installed.
If xhprof is not installed, hide profiling admin settings,
else show them.
This is needed, because if xhprof is installed, then it will
fail all non-js behats which navigate to setting under
site administration, as profiling settings get displayed on
default admin page.
  • Loading branch information
Rajesh Taneja committed Apr 7, 2014
1 parent 1a727e1 commit 22001b4
Showing 1 changed file with 40 additions and 42 deletions.
82 changes: 40 additions & 42 deletions admin/settings/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,48 +41,46 @@
$temp->add(new admin_setting_configcheckbox('debugpageinfo', new lang_string('debugpageinfo', 'admin'), new lang_string('configdebugpageinfo', 'admin'), 0));
$ADMIN->add('development', $temp);

// "profiling" settingpage (conditionally if the 'xhprof' extension is available only)
if (extension_loaded('xhprof') && function_exists('xhprof_enable')) {
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'));
// Main profiling switch
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
// List of URLs that will be automatically profiled
$temp->add(new admin_setting_configtextarea('profilingincluded', new lang_string('profilingincluded', 'admin'), new lang_string('profilingincluded_help', 'admin'), ''));
// List of URLs that won't be profiled ever
$temp->add(new admin_setting_configtextarea('profilingexcluded', new lang_string('profilingexcluded', 'admin'), new lang_string('profilingexcluded_help', 'admin'), ''));
// Allow random profiling each XX requests
$temp->add(new admin_setting_configtext('profilingautofrec', new lang_string('profilingautofrec', 'admin'), new lang_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
// Allow PROFILEME/DONTPROFILEME GPC
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
// Allow PROFILEALL/PROFILEALLSTOP GPC
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
// TODO: Allow to skip call_user functions (ignored_functions array)
// Specify the life time (in minutes) of profiling runs
$temp->add(new admin_setting_configselect('profilinglifetime', new lang_string('profilinglifetime', 'admin'), new lang_string('profilinglifetime_help', 'admin'), 24*60, array(
0 => new lang_string('neverdeleteruns', 'admin'),
30*24*60 => new lang_string('numdays', '', 30),
15*24*60 => new lang_string('numdays', '', 15),
7*24*60 => new lang_string('numdays', '', 7),
4*24*60 => new lang_string('numdays', '', 4),
2*24*60 => new lang_string('numdays', '', 2),
24*60 => new lang_string('numhours', '', 24),
16*80 => new lang_string('numhours', '', 16),
8*60 => new lang_string('numhours', '', 8),
4*60 => new lang_string('numhours', '', 4),
2*60 => new lang_string('numhours', '', 2),
60 => new lang_string('numminutes', '', 60),
30 => new lang_string('numminutes', '', 30),
15 => new lang_string('numminutes', '', 15))));
// Define the prefix to be added to imported profiling runs.
$temp->add(new admin_setting_configtext('profilingimportprefix',
new lang_string('profilingimportprefix', 'admin'),
new lang_string('profilingimportprefix_desc', 'admin'), '(I)', PARAM_TAG, 10));

// Add the 'profiling' page to admin block
$ADMIN->add('development', $temp);
}

// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
$xhprofenabled = extension_loaded('xhprof') && function_exists('xhprof_enable');
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'), 'moodle/site:config', !$xhprofenabled);
// Main profiling switch.
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
// List of URLs that will be automatically profiled.
$temp->add(new admin_setting_configtextarea('profilingincluded', new lang_string('profilingincluded', 'admin'), new lang_string('profilingincluded_help', 'admin'), ''));
// List of URLs that won't be profiled ever.
$temp->add(new admin_setting_configtextarea('profilingexcluded', new lang_string('profilingexcluded', 'admin'), new lang_string('profilingexcluded_help', 'admin'), ''));
// Allow random profiling each XX requests.
$temp->add(new admin_setting_configtext('profilingautofrec', new lang_string('profilingautofrec', 'admin'), new lang_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
// Allow PROFILEME/DONTPROFILEME GPC.
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
// Allow PROFILEALL/PROFILEALLSTOP GPC.
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
// TODO: Allow to skip call_user functions (ignored_functions array)
// Specify the life time (in minutes) of profiling runs.
$temp->add(new admin_setting_configselect('profilinglifetime', new lang_string('profilinglifetime', 'admin'), new lang_string('profilinglifetime_help', 'admin'), 24*60, array(
0 => new lang_string('neverdeleteruns', 'admin'),
30*24*60 => new lang_string('numdays', '', 30),
15*24*60 => new lang_string('numdays', '', 15),
7*24*60 => new lang_string('numdays', '', 7),
4*24*60 => new lang_string('numdays', '', 4),
2*24*60 => new lang_string('numdays', '', 2),
24*60 => new lang_string('numhours', '', 24),
16*80 => new lang_string('numhours', '', 16),
8*60 => new lang_string('numhours', '', 8),
4*60 => new lang_string('numhours', '', 4),
2*60 => new lang_string('numhours', '', 2),
60 => new lang_string('numminutes', '', 60),
30 => new lang_string('numminutes', '', 30),
15 => new lang_string('numminutes', '', 15))));
// Define the prefix to be added to imported profiling runs.
$temp->add(new admin_setting_configtext('profilingimportprefix',
new lang_string('profilingimportprefix', 'admin'),
new lang_string('profilingimportprefix_desc', 'admin'), '(I)', PARAM_TAG, 10));

// Add the 'profiling' page to admin block.
$ADMIN->add('development', $temp);

// Web service test clients DO NOT COMMIT : THE EXTERNAL WEB PAGE IS NOT AN ADMIN PAGE !!!!!
$ADMIN->add('development', new admin_externalpage('testclient', new lang_string('testclient', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/testclient.php"));
Expand Down

0 comments on commit 22001b4

Please sign in to comment.