Skip to content

Commit cd94a2f

Browse files
committed
Profiler/Misc
* fix realm selection in profiler filters * minor cleanup of prQueue
1 parent 91bb53a commit cd94a2f

File tree

5 files changed

+53
-98
lines changed

5 files changed

+53
-98
lines changed

includes/types/arenateam.class.php

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function getJSGlobals($addMask = 0) {}
4646

4747
class ArenaTeamListFilter extends Filter
4848
{
49+
use TrProfilerFilter;
50+
4951
public $extraOpts = [];
5052
protected $genericFilter = [];
5153

@@ -86,33 +88,6 @@ protected function createSQLForValues()
8688

8789
return $parts;
8890
}
89-
90-
protected function cbRegionCheck(string &$v) : bool
91-
{
92-
if (in_array($v, Util::$regions))
93-
{
94-
$this->parentCats[0] = $v; // directly redirect onto this region
95-
$v = ''; // remove from filter
96-
97-
return true;
98-
}
99-
100-
return false;
101-
}
102-
103-
protected function cbServerCheck(string &$v) : bool
104-
{
105-
foreach (Profiler::getRealms() as $realm)
106-
if ($realm['name'] == $v)
107-
{
108-
$this->parentCats[1] = Profiler::urlize($v);// directly redirect onto this server
109-
$v = ''; // remove from filter
110-
111-
return true;
112-
}
113-
114-
return false;
115-
}
11691
}
11792

11893

includes/types/basetype.class.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,37 @@ public function getSources(?array &$s = [], ?array &$sm = []) : bool
918918
}
919919
}
920920

921+
trait TrProfilerFilter
922+
{
923+
protected function cbRegionCheck(string &$v) : bool
924+
{
925+
if (in_array($v, Util::$regions))
926+
{
927+
$this->parentCats[0] = $v; // directly redirect onto this region
928+
$v = ''; // remove from filter
929+
930+
return true;
931+
}
932+
933+
return false;
934+
}
935+
936+
protected function cbServerCheck(string &$v) : bool
937+
{
938+
foreach (Profiler::getRealms() as $realm)
939+
{
940+
if (Profiler::urlize($realm['name']) != $v)
941+
continue;
942+
943+
$this->parentCats[1] = $v; // directly redirect onto this server
944+
$v = ''; // remove from filter
945+
946+
return true;
947+
}
948+
949+
return false;
950+
}
951+
}
921952

922953
abstract class Filter
923954
{

includes/types/guild.class.php

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public function getJSGlobals($addMask = 0) {}
8989

9090
class GuildListFilter extends Filter
9191
{
92+
use TrProfilerFilter;
93+
9294
public $extraOpts = [];
9395
protected $genericFilter = [];
9496

@@ -124,33 +126,6 @@ protected function createSQLForValues()
124126

125127
return $parts;
126128
}
127-
128-
protected function cbRegionCheck(string &$v) : bool
129-
{
130-
if (in_array($v, Util::$regions))
131-
{
132-
$this->parentCats[0] = $v; // directly redirect onto this region
133-
$v = ''; // remove from filter
134-
135-
return true;
136-
}
137-
138-
return false;
139-
}
140-
141-
protected function cbServerCheck(string &$v) : bool
142-
{
143-
foreach (Profiler::getRealms() as $realm)
144-
if ($realm['name'] == $v)
145-
{
146-
$this->parentCats[1] = Profiler::urlize($v);// directly redirect onto this server
147-
$v = ''; // remove from filter
148-
149-
return true;
150-
}
151-
152-
return false;
153-
}
154129
}
155130

156131

includes/types/profile.class.php

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ public function getIcon()
239239

240240
class ProfileListFilter extends Filter
241241
{
242+
use TrProfilerFilter;
243+
242244
public $useLocalList = false;
243245
public $extraOpts = [];
244246

@@ -359,33 +361,6 @@ protected function createSQLForValues()
359361
return $parts;
360362
}
361363

362-
protected function cbRegionCheck(string &$v) : bool
363-
{
364-
if (in_array($v, Util::$regions))
365-
{
366-
$this->parentCats[0] = $v; // directly redirect onto this region
367-
$v = ''; // remove from filter
368-
369-
return true;
370-
}
371-
372-
return false;
373-
}
374-
375-
protected function cbServerCheck(string &$v) : bool
376-
{
377-
foreach (Profiler::getRealms() as $realm)
378-
if ($realm['name'] == $v)
379-
{
380-
$this->parentCats[1] = Profiler::urlize($v);// directly redirect onto this server
381-
$v = ''; // remove from filter
382-
383-
return true;
384-
}
385-
386-
return false;
387-
}
388-
389364
protected function cbProfession(int $cr, int $crs, string $crv, $skillId) : ?array
390365
{
391366
if (!Util::checkNumeric($crv, NUM_CAST_INT) || !$this->int2Op($crs))

prQueue

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ CLI::write('profiler queue started', CLI::LOG_OK);
2929
set_time_limit(0);
3030
$tCycle = microtime(true);
3131

32-
$error = function ($type, $realmGUID, $realmId)
32+
$error = function (int $type, int $realmGUID, int $realmId) : void
3333
{
34-
$what = '';
35-
if ($type == Type::PROFILE)
36-
$what = 'char';
37-
if ($type == Type::GUILD)
38-
$what = 'guild';
39-
if ($type == Type::ARENA_TEAM)
40-
$what = 'arena team';
41-
42-
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d, errorCode = ?d WHERE realm = ?d AND realmGUID = ?d AND type = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_CHAR, $realmId, $realmGUID, $type);
34+
$what = match ($type)
35+
{
36+
Type::PROFILE => 'char',
37+
Type::GUILD => 'guild',
38+
Type::ARENA_TEAM => 'arena team'
39+
};
40+
41+
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d, `errorCode` = ?d WHERE `realm` = ?d AND `realmGUID` = ?d AND `type` = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_CHAR, $realmId, $realmGUID, $type);
4342
trigger_error('prQueue - '.$what.' #'.$realmGUID.' on realm #'.$realmId.' not found. Truncating local placeholder.', E_USER_WARNING);
4443
};
4544

@@ -54,7 +53,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
5453
usleep($wait * 1000 * 1000);
5554
}
5655

57-
$row = DB::Aowow()->selectRow('SELECT * FROM ?_profiler_sync WHERE status = ?d ORDER BY requestTime ASC', PR_QUEUE_STATUS_WAITING);
56+
$row = DB::Aowow()->selectRow('SELECT * FROM ?_profiler_sync WHERE `status` = ?d ORDER BY `requestTime` ASC', PR_QUEUE_STATUS_WAITING);
5857
if (!$row)
5958
{
6059
// nothing more to do
@@ -68,20 +67,20 @@ while (Cfg::get('PROFILER_ENABLE', true))
6867

6968
if (empty(Profiler::getRealms()[$row['realm']]))
7069
{
71-
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d, errorCode = ?d WHERE realm = ?d AND type = ?d AND typeId = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_ARMORY, $row['realm'], $row['type'], $row['typeId']);
70+
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d, `errorCode` = ?d WHERE `realm` = ?d AND `type` = ?d AND `typeId` = ?d', PR_QUEUE_STATUS_ERROR, PR_QUEUE_ERROR_ARMORY, $row['realm'], $row['type'], $row['typeId']);
7271
CLI::write('realm #'.$row['realm'].' for subject guid '.$row['realmGUID'].' is undefined', CLI::LOG_WARN);
7372
continue;
7473
}
7574
else
76-
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d WHERE realm = ?d AND type = ?d AND typeId = ?d', PR_QUEUE_STATUS_WORKING, $row['realm'], $row['type'], $row['typeId']);
75+
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d WHERE `realm` = ?d AND `type` = ?d AND `typeId` = ?d', PR_QUEUE_STATUS_WORKING, $row['realm'], $row['type'], $row['typeId']);
7776

7877
switch ($row['type'])
7978
{
8079
case Type::PROFILE:
8180
if (!Profiler::getCharFromRealm($row['realm'], $row['realmGUID']))
8281
{
8382
$error(Type::PROFILE, $row['realmGUID'], $row['realm']);
84-
DB::Aowow()->query('DELETE FROM ?_profiler_profiles WHERE realm = ?d AND realmGUID = ?d', $row['realm'], $row['realmGUID']);
83+
DB::Aowow()->query('DELETE FROM ?_profiler_profiles WHERE `realm` = ?d AND `realmGUID` = ?d', $row['realm'], $row['realmGUID']);
8584
continue 2;
8685
}
8786

@@ -90,7 +89,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
9089
if (!Profiler::getGuildFromRealm($row['realm'], $row['realmGUID']))
9190
{
9291
$error(Type::GUILD, $row['realmGUID'], $row['realm']);
93-
DB::Aowow()->query('DELETE FROM ?_profiler_guild WHERE realm = ?d AND realmGUID = ?d', $row['realm'], $row['realmGUID']);
92+
DB::Aowow()->query('DELETE FROM ?_profiler_guild WHERE `realm` = ?d AND `realmGUID` = ?d', $row['realm'], $row['realmGUID']);
9493
continue 2;
9594
}
9695

@@ -99,7 +98,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
9998
if (!Profiler::getArenaTeamFromRealm($row['realm'], $row['realmGUID']))
10099
{
101100
$error(Type::ARENA_TEAM, $row['realmGUID'], $row['realm']);
102-
DB::Aowow()->query('DELETE FROM ?_profiler_arena_team WHERE realm = ?d AND realmGUID = ?d', $row['realm'], $row['realmGUID']);
101+
DB::Aowow()->query('DELETE FROM ?_profiler_arena_team WHERE `realm` = ?d AND `realmGUID` = ?d', $row['realm'], $row['realmGUID']);
103102
continue 2;
104103
}
105104

@@ -112,7 +111,7 @@ while (Cfg::get('PROFILER_ENABLE', true))
112111
$tCycle = microtime(true);
113112

114113
// mark as ready
115-
DB::Aowow()->query('UPDATE ?_profiler_sync SET status = ?d, errorCode = 0 WHERE realm = ?d AND type = ?d AND typeId = ?d', PR_QUEUE_STATUS_READY, $row['realm'], $row['type'], $row['typeId']);
114+
DB::Aowow()->query('UPDATE ?_profiler_sync SET `status` = ?d, `errorCode` = 0 WHERE `realm` = ?d AND `type` = ?d AND `typeId` = ?d', PR_QUEUE_STATUS_READY, $row['realm'], $row['type'], $row['typeId']);
116115
}
117116

118117
Profiler::queueFree();

0 commit comments

Comments
 (0)