Skip to content

Commit

Permalink
Revert "MDL-39474 Library: Make a fast way to check developer debug m…
Browse files Browse the repository at this point in the history
…ode"

There were multiple problems discovered.

This reverts commit 5c92e7a.

Conflicts:
	admin/cli/install.php
  • Loading branch information
danpoltawski committed Jun 18, 2013
1 parent da107ae commit 3d164e1
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 20 deletions.
1 change: 0 additions & 1 deletion admin/cli/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
$CFG->running_installer = true;
$CFG->early_install_lang = true;
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
$CFG->developerdebug = true;
$CFG->dboptions = array();

$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
Expand Down
3 changes: 1 addition & 2 deletions cache/classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,8 @@ public static function get_definition_name($definition) {
* @return string
*/
public static function hash_key($key, cache_definition $definition) {
global $CFG;
if ($definition->uses_simple_keys()) {
if ($CFG->developerdebug && preg_match('#[^a-zA-Z0-9_]#', $key)) {
if (debugging() && preg_match('#[^a-zA-Z0-9_]#', $key)) {
throw new coding_exception('Cache definition '.$definition->get_id().' requires simple keys. Invalid key provided.', $key);
}
// We put the key first so that we can be sure the start of the key changes.
Expand Down
1 change: 0 additions & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
$CFG->running_installer = true;
$CFG->early_install_lang = true;
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
$CFG->developerdebug = true;

// Require all needed libs
require_once($CFG->libdir.'/setuplib.php');
Expand Down
5 changes: 2 additions & 3 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7579,7 +7579,7 @@ function get_string($identifier, $component = '', $a = NULL, $lazyload = false)
return new lang_string($identifier, $component, $a);
}

if ($CFG->developerdebug && clean_param($identifier, PARAM_STRINGID) === '') {
if (debugging('', DEBUG_DEVELOPER) && clean_param($identifier, PARAM_STRINGID) === '') {
throw new coding_exception('Invalid string identifier. The identifier cannot be empty. Please fix your get_string() call.');
}

Expand Down Expand Up @@ -11376,7 +11376,6 @@ class lang_string {
* @param string $lang The language to use when processing the string.
*/
public function __construct($identifier, $component = '', $a = null, $lang = null) {
global $CFG;
if (empty($component)) {
$component = 'moodle';
}
Expand Down Expand Up @@ -11414,7 +11413,7 @@ public function __construct($identifier, $component = '', $a = null, $lang = nul
}
}

if ($CFG->developerdebug) {
if (debugging(false, DEBUG_DEVELOPER)) {
if (clean_param($this->identifier, PARAM_STRINGID) == '') {
throw new coding_exception('Invalid string identifier. Most probably some illegal character is part of the string identifier. Please check your string definition');
}
Expand Down
10 changes: 0 additions & 10 deletions lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@
}
}

// The 'developerdebug' value is relied upon by various functions, so set it
// immediately (before debugging value is actually known).
if (!isset($CFG->developerdebug)) {
$tempdeveloperdebug = true;
$CFG->developerdebug = false;
}

// We can detect real dirroot path reliably since PHP 4.0.2,
// it can not be anything else, there is no point in having this in config.php
$CFG->dirroot = dirname(dirname(__FILE__));
Expand Down Expand Up @@ -619,9 +612,6 @@
unset($originalconfigdebug);
unset($originaldatabasedebug);
error_reporting($CFG->debug);
if (!empty($tempdeveloperdebug)) {
$CFG->developerdebug = debugging('', DEBUG_DEVELOPER);
}

// find out if PHP configured to display warnings,
// this is a security problem because some moodle scripts may
Expand Down
3 changes: 0 additions & 3 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ information provided here is intended especially for developers.
uninstall tool is returned. Unless the plugin type needs extra steps that can't be handled by
plugininfo_xxx::uninstall() method or xmldb_xxx_uninstall() function, this default URL should
satisfy all plugin types.
* New pattern 'if ($CFG->developerdebug) {}' can be used when checking whether to carry
out additional sanity checks - faster than debugging('', DEBUG_DEVELOPER), but
that still works too.

Database (DML) layer:
* $DB->sql_empty() is deprecated, you have to use sql parameters with empty values instead,
Expand Down

0 comments on commit 3d164e1

Please sign in to comment.