Config/Profiler

* update config to enable/disable profiler in general, instead of just the queue
 * regenerate affected files on config change
This commit is contained in:
Sarjuuk
2018-03-27 12:39:14 +02:00
parent c17cf9c043
commit 22d02378ef
13 changed files with 37 additions and 7 deletions

View File

@@ -471,7 +471,8 @@ class AjaxAdmin extends AjaxHandler
$msg .= ' * remember to rebuild all static files for the language you just added.<br />'; $msg .= ' * remember to rebuild all static files for the language you just added.<br />';
$msg .= ' * you can speed this up by supplying the regionCode to the setup: <pre class="q1">--locales=<regionCodes,> -f</pre>'; $msg .= ' * you can speed this up by supplying the regionCode to the setup: <pre class="q1">--locales=<regionCodes,> -f</pre>';
break; break;
case 'profiler_queue': case 'profiler_enable':
$buildList = 'realms,realmMenu';
$fn = function($x) use (&$msg) { $fn = function($x) use (&$msg) {
if (!$x) if (!$x)
return true; return true;

View File

@@ -47,6 +47,9 @@ class AjaxProfile extends AjaxHandler
if (!$this->params) if (!$this->params)
return; return;
if (!CFG_PROFILER_ENABLE)
return;
switch ($this->params[0]) switch ($this->params[0])
{ {
case 'unlink': case 'unlink':

View File

@@ -244,7 +244,7 @@ class Profiler
public static function resyncStatus($type, array $subjectGUIDs) public static function resyncStatus($type, array $subjectGUIDs)
{ {
$response = [CFG_PROFILER_QUEUE ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2 $response = [CFG_PROFILER_ENABLE ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2
if (!$subjectGUIDs) if (!$subjectGUIDs)
$response[] = [PR_QUEUE_STATUS_ENDED, 0, 0, PR_QUEUE_ERROR_CHAR]; $response[] = [PR_QUEUE_STATUS_ENDED, 0, 0, PR_QUEUE_ERROR_CHAR];
else else

View File

@@ -20,6 +20,9 @@ class ArenaTeamPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
if (!CFG_PROFILER_ENABLE)
$this->error();
$params = array_map('urldecode', explode('.', $pageParam)); $params = array_map('urldecode', explode('.', $pageParam));
if ($params[0]) if ($params[0])
$params[0] = Profiler::urlize($params[0]); $params[0] = Profiler::urlize($params[0]);

View File

@@ -17,6 +17,9 @@ class ArenaTeamsPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
if (!CFG_PROFILER_ENABLE)
$this->error();
$this->getSubjectFromUrl($pageParam); $this->getSubjectFromUrl($pageParam);
$this->filterObj = new ArenaTeamListFilter(); $this->filterObj = new ArenaTeamListFilter();

View File

@@ -20,6 +20,9 @@ class GuildPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
if (!CFG_PROFILER_ENABLE)
$this->error();
$params = array_map('urldecode', explode('.', $pageParam)); $params = array_map('urldecode', explode('.', $pageParam));
if ($params[0]) if ($params[0])
$params[0] = Profiler::urlize($params[0]); $params[0] = Profiler::urlize($params[0]);

View File

@@ -17,6 +17,9 @@ class GuildsPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
if (!CFG_PROFILER_ENABLE)
$this->error();
$this->getSubjectFromUrl($pageParam); $this->getSubjectFromUrl($pageParam);
$this->filterObj = new GuildListFilter(); $this->filterObj = new GuildListFilter();

View File

@@ -13,6 +13,14 @@ class ProfilerPage extends GenericPage
protected $js = ['profile_all.js', 'profile.js']; protected $js = ['profile_all.js', 'profile.js'];
protected $css = [['path' => 'Profiler.css']]; protected $css = [['path' => 'Profiler.css']];
public function __construct($pageCall, $pageParam)
{
if (!CFG_PROFILER_ENABLE)
$this->error();
parent::__construct($pageCall, $pageParam);
}
protected function generateContent() protected function generateContent()
{ {
$this->addJS('?data=realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']); $this->addJS('?data=realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']);

View File

@@ -20,6 +20,9 @@ class ProfilesPage extends GenericPage
public function __construct($pageCall, $pageParam) public function __construct($pageCall, $pageParam)
{ {
if (!CFG_PROFILER_ENABLE)
$this->error();
$this->getSubjectFromUrl($pageParam); $this->getSubjectFromUrl($pageParam);
$realms = []; $realms = [];

View File

@@ -41,8 +41,8 @@ $error = function ($type, $typeId, $realmId)
}; };
// if (CFG_PROFILER_QUEUE) - wont work because it is not redefined if changed in config // if (CFG_PROFILER_ENABLE) - wont work because it is not redefined if changed in config
while (DB::Aowow()->selectCell('SELECT value FROM ?_config WHERE `key` = "profiler_queue"')) while (DB::Aowow()->selectCell('SELECT value FROM ?_config WHERE `key` = "profiler_enable"'))
{ {
if (($tDiff = (microtime(true) - $tCycle)) < (CFG_PROFILER_QUEUE_DELAY / 1000)) if (($tDiff = (microtime(true) - $tCycle)) < (CFG_PROFILER_QUEUE_DELAY / 1000))
{ {

File diff suppressed because one or more lines are too long

View File

@@ -46,7 +46,8 @@ function siteconfig()
CLI::write(' * remember to rebuild all static files for the language you just added.', CLI::LOG_INFO); CLI::write(' * remember to rebuild all static files for the language you just added.', CLI::LOG_INFO);
CLI::write(' * you can speed this up by supplying the regionCode to the setup: '.CLI::bold('--locales=<regionCodes,> -f')); CLI::write(' * you can speed this up by supplying the regionCode to the setup: '.CLI::bold('--locales=<regionCodes,> -f'));
break; break;
case 'profiler_queue': case 'profiler_enable':
array_push($updScripts, 'realms', 'realmMenu');
$fn = function($x) { $fn = function($x) {
if (!$x) if (!$x)
return true; return true;

View File

@@ -0,0 +1,2 @@
DELETE FROM `aowow_config` WHERE `key` IN ('profiler_queue', 'profiler_enable');
INSERT INTO `aowow_config` VALUES ('profiler_enable', '0', 7, 132, 'default: 0 - enable/disable profiler feature');