Merge branch 'debugdeveloperbitwisemess' of git://github.com/skodak/moodle

This commit is contained in:
Dan Poltawski 2013-08-22 10:40:47 +08:00
commit c44ff50cbc
3 changed files with 43 additions and 3 deletions

View File

@ -339,7 +339,7 @@ if (isset($CFG->debug)) {
} else {
$CFG->debug = 0;
}
$CFG->debugdeveloper = ($CFG->debug & E_ALL and $CFG->debug & E_STRICT); // DEBUG_DEVELOPER is not available yet.
$CFG->debugdeveloper = (($CFG->debug & (E_ALL | E_STRICT)) === (E_ALL | E_STRICT)); // DEBUG_DEVELOPER is not available yet.
if (!defined('MOODLE_INTERNAL')) { // Necessary because cli installer has to define it earlier.
/** Used by library scripts to check they are being called by Moodle. */
@ -599,7 +599,7 @@ if (isset($CFG->debug)) {
} else {
$CFG->debug = 0;
}
$CFG->debugdeveloper = ($CFG->debug & DEBUG_DEVELOPER);
$CFG->debugdeveloper = (($CFG->debug & DEBUG_DEVELOPER) === DEBUG_DEVELOPER);
// Find out if PHP configured to display warnings,
// this is a security problem because some moodle scripts may

View File

@ -428,4 +428,44 @@ class core_weblib_testcase extends advanced_testcase {
$this->assertSame("do\n re\n mi\n", $trace2->get_buffer());
$this->expectOutputString('');
}
public function test_set_debugging() {
global $CFG;
$this->resetAfterTest();
$this->assertEquals(DEBUG_DEVELOPER, $CFG->debug);
$this->assertTrue($CFG->debugdeveloper);
$this->assertNotEmpty($CFG->debugdisplay);
set_debugging(DEBUG_DEVELOPER, true);
$this->assertEquals(DEBUG_DEVELOPER, $CFG->debug);
$this->assertTrue($CFG->debugdeveloper);
$this->assertNotEmpty($CFG->debugdisplay);
set_debugging(DEBUG_DEVELOPER, false);
$this->assertEquals(DEBUG_DEVELOPER, $CFG->debug);
$this->assertTrue($CFG->debugdeveloper);
$this->assertEmpty($CFG->debugdisplay);
set_debugging(-1);
$this->assertEquals(-1, $CFG->debug);
$this->assertTrue($CFG->debugdeveloper);
set_debugging(DEBUG_ALL);
$this->assertEquals(DEBUG_ALL, $CFG->debug);
$this->assertFalse($CFG->debugdeveloper);
set_debugging(DEBUG_NORMAL);
$this->assertEquals(DEBUG_NORMAL, $CFG->debug);
$this->assertFalse($CFG->debugdeveloper);
set_debugging(DEBUG_MINIMAL);
$this->assertEquals(DEBUG_MINIMAL, $CFG->debug);
$this->assertFalse($CFG->debugdeveloper);
set_debugging(DEBUG_NONE);
$this->assertEquals(DEBUG_NONE, $CFG->debug);
$this->assertFalse($CFG->debugdeveloper);
}
}

View File

@ -2802,7 +2802,7 @@ function set_debugging($level, $debugdisplay = null) {
global $CFG;
$CFG->debug = (int)$level;
$CFG->debugdeveloper = ($CFG->debug & DEBUG_DEVELOPER);
$CFG->debugdeveloper = (($CFG->debug & DEBUG_DEVELOPER) === DEBUG_DEVELOPER);
if ($debugdisplay !== null) {
$CFG->debugdisplay = (bool)$debugdisplay;