Permalink
Browse files

Merge branch 'w33_MDL-39474_m26_debugdeveloper' of https://github.com…

…/skodak/moodle

Conflicts:
	lib/upgrade.txt
  • Loading branch information...
danpoltawski committed Aug 20, 2013
2 parents 8ab325f + 96f81ea commit 6f44a7336959bacba07db161ae47dac9bfc906c2
Showing with 191 additions and 184 deletions.
  1. +1 −2 admin/cli/automated_backups.php
  2. +3 −0 admin/cli/install.php
  3. +1 −1 admin/tool/generator/cli/generate.php
  4. +1 −1 admin/tool/generator/index.php
  5. +3 −3 admin/tool/phpunit/webrunner.php
  6. +1 −1 auth/cas/cli/sync_users.php
  7. +1 −1 auth/ldap/cli/sync_users.php
  8. +1 −1 backup/util/factories/backup_factory.class.php
  9. +0 −1 backup/util/factories/tests/factories_test.php
  10. +2 −7 cache/tests/administration_helper_test.php
  11. +1 −1 enrol/ldap/cli/sync.php
  12. +3 −0 install.php
  13. +1 −1 lib/accesslib.php
  14. +3 −1 lib/adminlib.php
  15. +1 −4 lib/classes/component.php
  16. +18 −18 lib/classes/event/base.php
  17. +1 −2 lib/cronlib.php
  18. +3 −2 lib/dml/pdo_moodle_database.php
  19. +4 −8 lib/dml/tests/dml_test.php
  20. +1 −1 lib/editor/tinymce/classes/plugin.php
  21. +1 −1 lib/editor/tinymce/cli/update_lang_files.php
  22. +1 −1 lib/editor/tinymce/lib.php
  23. +4 −2 lib/filestorage/file_storage.php
  24. +4 −2 lib/formslib.php
  25. +1 −0 lib/installlib.php
  26. +1 −1 lib/minify/config.php
  27. +5 −5 lib/moodlelib.php
  28. +2 −1 lib/outputlib.php
  29. +2 −2 lib/outputrenderers.php
  30. +5 −5 lib/outputrequirementslib.php
  31. +1 −0 lib/phpunit/bootstrap.php
  32. +2 −1 lib/phpunit/classes/advanced_testcase.php
  33. +1 −0 lib/phpunit/classes/util.php
  34. +2 −1 lib/phpunit/tests/advanced_test.php
  35. +62 −77 lib/setup.php
  36. +16 −13 lib/setuplib.php
  37. +2 −2 lib/tests/event_test.php
  38. +4 −6 lib/tests/statslib_test.php
  39. +2 −0 lib/upgrade.txt
  40. +1 −1 lib/upgradelib.php
  41. +19 −1 lib/weblib.php
  42. +2 −1 mod/workshop/renderer.php
  43. +1 −5 report/performance/locallib.php
@@ -75,8 +75,7 @@
$DB->set_debug(true);
}
if (!empty($CFG->showcrondebugging)) {
$CFG->debug = DEBUG_DEVELOPER;
$CFG->debugdisplay = true;
set_debugging(DEBUG_DEVELOPER, true);
}
$starttime = microtime();
View
@@ -162,6 +162,9 @@
$CFG->early_install_lang = true;
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
$CFG->dboptions = array();
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = true;
$CFG->debugdeveloper = true;
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
$CFG->admin = array_pop($parts);
@@ -28,7 +28,7 @@
require(dirname(__FILE__) . '/../../../../config.php');
require_once(dirname(__FILE__) . '/../locallib.php');
if (!debugging('', DEBUG_DEVELOPER)) {
if (!$CFG->debugdeveloper) {
echo("This script is for developers only!!!\n");
exit(1);
}
@@ -34,7 +34,7 @@
error('Only for admins');
}
if (!debugging('', DEBUG_DEVELOPER)) {
if (!$CFG->debugdeveloper) {
error('This script is for developers only!!!');
}
@@ -34,7 +34,7 @@
navigation_node::override_active_url(new moodle_url('/admin/tool/phpunit/index.php'));
admin_externalpage_setup('toolphpunitwebrunner');
if (!debugging('', DEBUG_DEVELOPER)) {
if (!$CFG->debugdeveloper) {
error('Not available on production sites, sorry.');
}
@@ -82,7 +82,7 @@
if ($code != 0) {
tool_phpunit_problem('Can not initialize database');
}
$CFG->debug = 0; // no pesky redirect warning, we really want to redirect
set_debugging(DEBUG_NONE, false); // Hack: no redirect warning, we really want to redirect.
redirect(new moodle_url($PAGE->url, array('execute'=>1, 'tespath'=>$testpath, 'testclass'=>$testclass, 'sesskey'=>sesskey())), 'Reloading page');
echo $OUTPUT->footer();
die();
@@ -103,7 +103,7 @@
if ($code != 0) {
tool_phpunit_problem('Can not initialize database');
}
$CFG->debug = 0; // no pesky redirect warning, we really want to redirect
set_debugging(DEBUG_NONE, false); // Hack: no redirect warning, we really want to redirect.
redirect(new moodle_url($PAGE->url, array('execute'=>1, 'tespath'=>$testpath, 'testclass'=>$testclass, 'sesskey'=>sesskey())), 'Reloading page');
die();
@@ -48,7 +48,7 @@
require_once($CFG->dirroot.'/course/lib.php');
// Ensure errors are well explained
$CFG->debug = DEBUG_NORMAL;
set_debugging(DEBUG_DEVELOPER, true);
if (!is_enabled_auth('cas')) {
error_log('[AUTH CAS] '.get_string('pluginnotenabled', 'auth_ldap'));
@@ -52,7 +52,7 @@
require_once($CFG->dirroot.'/course/lib.php');
// Ensure errors are well explained
$CFG->debug = DEBUG_NORMAL;
set_debugging(DEBUG_DEVELOPER, true);
if (!is_enabled_auth('ldap')) {
error_log('[AUTH LDAP] '.get_string('pluginnotenabled', 'auth_ldap'));
@@ -40,7 +40,7 @@ public static function get_logger_chain($interactive, $execution, $backupid) {
global $CFG;
$dfltloglevel = backup::LOG_WARNING; // Default logging level
if (debugging('', DEBUG_DEVELOPER)) { // Debug developer raises default logging level
if ($CFG->debugdeveloper) { // Debug developer raises default logging level
$dfltloglevel = backup::LOG_DEBUG;
}
@@ -94,7 +94,6 @@ function test_backup_factory() {
// Instantiate with debugging enabled and $CFG->backup_error_log_logger_level not set
$CFG->debugdisplay = true;
$CFG->debug = DEBUG_DEVELOPER;
unset($CFG->backup_error_log_logger_level);
$logger1 = backup_factory::get_logger_chain(backup::INTERACTIVE_YES, backup::EXECUTION_INMEDIATE, 'test');
$this->assertTrue($logger1 instanceof error_log_logger); // 1st logger is error_log_logger
@@ -189,11 +189,8 @@ public function test_get_edit_store_form() {
* Test the hash_key functionality.
*/
public function test_hash_key() {
global $CFG;
$currentdebugging = $CFG->debug;
$CFG->debug = E_ALL;
$this->resetAfterTest();
set_debugging(DEBUG_ALL);
// First with simplekeys
$instance = cache_config_phpunittest::instance(true);
@@ -230,7 +227,5 @@ public function test_hash_key() {
$result = cache_helper::hash_key('test/test', $definition);
$this->assertEquals(sha1($definition->generate_single_key_prefix().'-test/test'), $result);
$CFG->debug = $currentdebugging;
}
}
View
@@ -46,7 +46,7 @@
require_once("$CFG->libdir/clilib.php");
// Ensure errors are well explained.
$CFG->debug = DEBUG_DEVELOPER;
set_debugging(DEBUG_DEVELOPER, true);
if (!enrol_is_enabled('ldap')) {
cli_error(get_string('pluginnotenabled', 'enrol_ldap'), 2);
View
@@ -181,6 +181,9 @@
$CFG->running_installer = true;
$CFG->early_install_lang = true;
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = true;
$CFG->debugdeveloper = true;
// Require all needed libs
require_once($CFG->libdir.'/setuplib.php');
View
@@ -3807,7 +3807,7 @@ function get_users_by_capability(context $context, $capability, $fields = '', $s
$fields = 'u.*';
}
} else {
if (debugging('', DEBUG_DEVELOPER) && strpos($fields, 'u.*') === false && strpos($fields, 'u.id') === false) {
if ($CFG->debugdeveloper && strpos($fields, 'u.*') === false && strpos($fields, 'u.id') === false) {
debugging('u.id must be included in the list of fields passed to get_users_by_capability().', DEBUG_DEVELOPER);
}
}
View
@@ -968,6 +968,8 @@ public function prune($name) {
* @return bool True if successfully added, false if $something can not be added.
*/
public function add($parentname, $something, $beforesibling = null) {
global $CFG;
$parent = $this->locate($parentname);
if (is_null($parent)) {
debugging('parent does not exist!');
@@ -979,7 +981,7 @@ public function add($parentname, $something, $beforesibling = null) {
debugging('error - parts of tree can be inserted only into parentable parts');
return false;
}
if (debugging('', DEBUG_DEVELOPER) && !is_null($this->locate($something->name))) {
if ($CFG->debugdeveloper && !is_null($this->locate($something->name))) {
// The name of the node is already used, simply warn the developer that this should not happen.
// It is intentional to check for the debug level before performing the check.
debugging('Duplicate admin page name: ' . $something->name, DEBUG_DEVELOPER);
@@ -195,12 +195,9 @@ protected static function init() {
protected static function is_developer() {
global $CFG;
// Note we can not rely on $CFG->debug here because DB is not initialised yet.
if (isset($CFG->config_php_settings['debug'])) {
// Standard moodle script.
$debug = (int)$CFG->config_php_settings['debug'];
} else if (isset($CFG->debug)) {
// Usually script with ABORT_AFTER_CONFIG.
$debug = (int)$CFG->debug;
} else {
return false;
}
View
@@ -108,7 +108,7 @@
* @throws \coding_exception
*/
public static final function create(array $data = null) {
global $PAGE, $USER;
global $PAGE, $USER, $CFG;
$data = (array)$data;
@@ -178,7 +178,7 @@
}
// Warn developers if they do something wrong.
if (debugging('', DEBUG_DEVELOPER)) { // This should be replaced by new $CFG->slowdebug flag if introduced.
if ($CFG->debugdeveloper) {
static $automatickeys = array('eventname', 'component', 'action', 'target', 'contextlevel', 'contextinstanceid', 'timecreated');
static $initkeys = array('crud', 'level', 'objecttable');
@@ -187,10 +187,10 @@
continue;
} else if (in_array($key, $automatickeys)) {
debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, it is set automatically");
debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, it is set automatically", DEBUG_DEVELOPER);
} else if (in_array($key, $initkeys)) {
debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, you need to set it in init() method");
debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, you need to set it in init() method", DEBUG_DEVELOPER);
} else if (!in_array($key, self::$fields)) {
debugging("Data key '$key' does not exist in \\core\\event\\base");
@@ -395,7 +395,7 @@ protected function get_legacy_logdata() {
* @throws \coding_exception
*/
protected final function validate_before_trigger() {
global $DB;
global $DB, $CFG;
if (empty($this->data['crud'])) {
throw new \coding_exception('crud must be specified in init() method of each method');
@@ -407,38 +407,38 @@ protected function get_legacy_logdata() {
throw new \coding_exception('objecttable must be specified in init() method if objectid present');
}
if (debugging('', DEBUG_DEVELOPER)) { // This should be replaced by new $CFG->slowdebug flag if introduced.
if ($CFG->debugdeveloper) {
// Ideally these should be coding exceptions, but we need to skip these for performance reasons
// on production servers.
if (!in_array($this->data['crud'], array('c', 'r', 'u', 'd'), true)) {
debugging("Invalid event crud value specified.");
debugging("Invalid event crud value specified.", DEBUG_DEVELOPER);
}
if (!is_number($this->data['level'])) {
debugging('Event property level must be a number');
debugging('Event property level must be a number', DEBUG_DEVELOPER);
}
if (self::$fields !== array_keys($this->data)) {
debugging('Number of event data fields must not be changed in event classes');
debugging('Number of event data fields must not be changed in event classes', DEBUG_DEVELOPER);
}
$encoded = json_encode($this->data['other']);
if ($encoded === false or $this->data['other'] !== json_decode($encoded, true)) {
debugging('other event data must be compatible with json encoding');
debugging('other event data must be compatible with json encoding', DEBUG_DEVELOPER);
}
if ($this->data['userid'] and !is_number($this->data['userid'])) {
debugging('Event property userid must be a number');
debugging('Event property userid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['courseid'] and !is_number($this->data['courseid'])) {
debugging('Event property courseid must be a number');
debugging('Event property courseid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['objectid'] and !is_number($this->data['objectid'])) {
debugging('Event property objectid must be a number');
debugging('Event property objectid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['relateduserid'] and !is_number($this->data['relateduserid'])) {
debugging('Event property relateduserid must be a number');
debugging('Event property relateduserid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['objecttable']) {
if (!$DB->get_manager()->table_exists($this->data['objecttable'])) {
debugging('Unknown table specified in objecttable field');
debugging('Unknown table specified in objecttable field', DEBUG_DEVELOPER);
}
}
}
@@ -521,17 +521,17 @@ protected function get_legacy_logdata() {
* @throws \coding_exception if used after ::trigger()
*/
public final function add_record_snapshot($tablename, $record) {
global $DB;
global $DB, $CFG;
if ($this->triggered) {
throw new \coding_exception('It is not possible to add snapshots after triggering of events');
}
// NOTE: this might use some kind of MUC cache,
// hopefully we will not run out of memory here...
if (debugging('', DEBUG_DEVELOPER)) { // This should be replaced by new $CFG->slowdebug flag if introduced.
if ($CFG->debugdeveloper) {
if (!$DB->get_manager()->table_exists($tablename)) {
debugging("Invalid table name '$tablename' specified, database table does not exist.");
debugging("Invalid table name '$tablename' specified, database table does not exist.", DEBUG_DEVELOPER);
}
}
$this->recordsnapshots[$tablename][$record->id] = $record;
View
@@ -46,8 +46,7 @@ function cron_run() {
$DB->set_debug(true);
}
if (!empty($CFG->showcrondebugging)) {
$CFG->debug = DEBUG_DEVELOPER;
$CFG->debugdisplay = true;
set_debugging(DEBUG_DEVELOPER, true);
}
set_time_limit(0);
@@ -308,16 +308,17 @@ public function get_fieldset_sql($sql, array $params=null) {
* @return array of objects, or empty array if no records were found, or false if an error occurred.
*/
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
global $CFG;
$rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum);
if (!$rs->valid()) {
$rs->close(); // Not going to iterate (but exit), close rs
return false;
}
$objects = array();
$debugging = debugging('', DEBUG_DEVELOPER);
foreach($rs as $value) {
$key = reset($value);
if ($debugging && array_key_exists($key, $objects)) {
if ($CFG->debugdeveloper && array_key_exists($key, $objects)) {
debugging("Did you remember to make the first column something unique in your call to get_records? Duplicate value '$key' found in column first column of '$sql'.", DEBUG_DEVELOPER);
}
$objects[$key] = (object)$value;
View
@@ -1475,8 +1475,6 @@ public function test_get_records_list() {
}
public function test_get_records_sql() {
global $CFG;
$DB = $this->tdb;
$dbman = $DB->get_manager();
@@ -1518,11 +1516,11 @@ public function test_get_records_sql() {
$records = $DB->get_records_sql("SELECT course AS id, course AS course FROM {{$tablename}}", null);
$this->assertDebuggingCalled();
$this->assertEquals(6, count($records));
$CFG->debug = DEBUG_MINIMAL;
set_debugging(DEBUG_MINIMAL);
$records = $DB->get_records_sql("SELECT course AS id, course AS course FROM {{$tablename}}", null);
$this->assertDebuggingNotCalled();
$this->assertEquals(6, count($records));
$CFG->debug = DEBUG_DEVELOPER;
set_debugging(DEBUG_DEVELOPER);
// negative limits = no limits
$records = $DB->get_records_sql("SELECT * FROM {{$tablename}} ORDER BY id", null, -1, -1);
@@ -1734,8 +1732,6 @@ public function test_get_record_select() {
}
public function test_get_record_sql() {
global $CFG;
$DB = $this->tdb;
$dbman = $DB->get_manager();
@@ -1774,10 +1770,10 @@ public function test_get_record_sql() {
$this->assertNotEmpty($DB->get_record_sql("SELECT * FROM {{$tablename}}", array(), IGNORE_MISSING));
$this->assertDebuggingCalled();
$CFG->debug = DEBUG_MINIMAL;
set_debugging(DEBUG_MINIMAL);
$this->assertNotEmpty($DB->get_record_sql("SELECT * FROM {{$tablename}}", array(), IGNORE_MISSING));
$this->assertDebuggingNotCalled();
$CFG->debug = DEBUG_DEVELOPER;
set_debugging(DEBUG_DEVELOPER);
// multiple matches ignored
$this->assertNotEmpty($DB->get_record_sql("SELECT * FROM {{$tablename}}", array(), IGNORE_MULTIPLE));
@@ -360,7 +360,7 @@ public function get_tinymce_file_url($file='', $absolute=true) {
// Version number comes from plugin version.php, except in developer
// mode where the special string 'dev' is used (prevents cacheing and
// serves unminified JS).
if (debugging('', DEBUG_DEVELOPER)) {
if ($CFG->debugdeveloper) {
$version = '-1';
} else {
$version = $this->get_version();
@@ -26,7 +26,7 @@
require __DIR__ . '/../../../../config.php';
if (!debugging('', DEBUG_DEVELOPER)) {
if (!$CFG->debugdeveloper) {
die('Only for developers!!!!!');
}
@@ -100,7 +100,7 @@ public function head_setup() {
public function use_editor($elementid, array $options=null, $fpoptions=null) {
global $PAGE, $CFG;
// Note: use full moodle_url instance to prevent standard JS loader, make sure we are using https on profile page if required.
if (debugging('', DEBUG_DEVELOPER)) {
if ($CFG->debugdeveloper) {
$PAGE->requires->js(new moodle_url($CFG->httpswwwroot.'/lib/editor/tinymce/tiny_mce/'.$this->version.'/tiny_mce_src.js'));
} else {
$PAGE->requires->js(new moodle_url($CFG->httpswwwroot.'/lib/editor/tinymce/tiny_mce/'.$this->version.'/tiny_mce.js'));
Oops, something went wrong.

0 comments on commit 6f44a73

Please sign in to comment.