Merge pull request #6725 from nupplaphil/6691-rendertime-fix

Addon loading fix
This commit is contained in:
Hypolite Petovan 2019-02-22 23:53:11 -05:00 committed by GitHub
commit c1896eee34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 4 deletions

View file

@ -360,10 +360,15 @@ class App
$this->getMode()->determine($this->basePath); $this->getMode()->determine($this->basePath);
if ($this->getMode()->has(App\Mode::DBAVAILABLE)) { if ($this->getMode()->has(App\Mode::DBAVAILABLE)) {
Core\Hook::loadHooks();
$loader = new ConfigCacheLoader($this->basePath); $loader = new ConfigCacheLoader($this->basePath);
Core\Hook::callAll('load_config', $loader);
$this->config->getCache()->load($loader->loadCoreConfig('addon'), true); $this->config->getCache()->load($loader->loadCoreConfig('addon'), true);
$this->profiler->update(
$this->config->get('system', 'profiler', false),
$this->config->get('rendertime', 'callstack', false));
Core\Hook::loadHooks();
Core\Hook::callAll('load_config', $loader);
} }
$this->loadDefaultTimezone(); $this->loadDefaultTimezone();

View file

@ -42,6 +42,18 @@ class Profiler implements ContainerInterface
return $this->rendertime; return $this->rendertime;
} }
/**
* Updates the enabling of the current profiler
*
* @param bool $enabled
* @param bool $renderTime
*/
public function update($enabled = false, $renderTime = false)
{
$this->enabled = $enabled;
$this->rendertime = $renderTime;
}
/** /**
* @param bool $enabled True, if the Profiler is enabled * @param bool $enabled True, if the Profiler is enabled
* @param bool $renderTime True, if the Profiler should measure the whole rendertime including functions * @param bool $renderTime True, if the Profiler should measure the whole rendertime including functions

View file

@ -189,13 +189,29 @@ class ProfilerTest extends MockedTest
} }
/** /**
* Test if no rendertime is set * Test different enable and disable states of the profiler
*/ */
public function testNoRenderTime() public function testEnableDisable()
{ {
$profiler = new Profiler(true, false); $profiler = new Profiler(true, false);
$this->assertFalse($profiler->isRendertime()); $this->assertFalse($profiler->isRendertime());
$this->assertEmpty($profiler->getRendertimeString()); $this->assertEmpty($profiler->getRendertimeString());
$profiler->saveTimestamp(time(), 'network', 'test1');
$profiler->update(false, false);
$this->assertFalse($profiler->isRendertime());
$this->assertEmpty($profiler->getRendertimeString());
$profiler->update(true, true);
$profiler->saveTimestamp(time(), 'database', 'test2');
$this->assertTrue($profiler->isRendertime());
$output = $profiler->getRendertimeString();
$this->assertRegExp('/test1: \d+/', $output);
$this->assertRegExp('/test2: \d+/', $output);
} }
} }