Skip to content

Commit aeeb4b1

Browse files
committed
Filter/Errors
* move checks to __construct so they can be run on $_POST data and don't create malformed filter urls * if we received malformed $_GET params, build new params and reload * do not store error state in cache * cleanup
1 parent c0097f3 commit aeeb4b1

File tree

18 files changed

+265
-198
lines changed

18 files changed

+265
-198
lines changed

endpoints/achievements/achievements.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public function __construct(string $pageParam)
5454

5555
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
5656
$this->filter = new AchievementListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
57+
if ($this->filter->shouldReload)
58+
{
59+
$_SESSION['error']['fi'] = $this->filter::class;
60+
$get = $this->filter->buildGETParam();
61+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
62+
}
5763
$this->filterError = $this->filter->error;
5864
}
5965

@@ -69,13 +75,9 @@ protected function generate() : void
6975
if ($this->category)
7076
$conditions[] = ['category', end($this->category)];
7177

72-
$this->filter->evalCriteria();
73-
7478
if ($fiCnd = $this->filter->getConditions())
7579
$conditions[] = $fiCnd;
7680

77-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
78-
7981

8082
/*************/
8183
/* Menu Path */

endpoints/areatriggers/areatriggers.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ public function __construct(string $pageParam)
3333
parent::__construct($pageParam);
3434

3535
$this->filter = new AreaTriggerListFilter($this->_get['filter'] ?? '');
36+
if ($this->filter->shouldReload)
37+
{
38+
$_SESSION['error']['fi'] = $this->filter::class;
39+
$get = $this->filter->buildGETParam();
40+
$this->forward('?' . $this->pageName . ($get ? '&filter=' . $get : ''));
41+
}
3642
$this->filterError = $this->filter->error;
3743
}
3844

3945
protected function generate() : void
4046
{
4147
$this->h1 = Util::ucFirst(Lang::game('areatriggers'));
4248

43-
$this->filter->evalCriteria();
44-
4549
$fiForm = $this->filter->values;
4650

4751

@@ -73,8 +77,6 @@ protected function generate() : void
7377
if ($_ = $this->filter->getConditions())
7478
$conditions[] = $_;
7579

76-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
77-
7880
$tabData = [];
7981
$trigger = new AreaTriggerList($conditions, ['calcTotal' => true]);
8082
if (!$trigger->error)

endpoints/arena-teams/arena-teams.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public function __construct(string $pageParam)
5353

5454
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
5555
$this->filter = new ArenaTeamListFilter($this->_get['filter'] ?? '', ['realms' => $realms]);
56+
if ($this->filter->shouldReload)
57+
{
58+
$_SESSION['error']['fi'] = $this->filter::class;
59+
$get = $this->filter->buildGETParam();
60+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
61+
}
5662
$this->filterError = $this->filter->error;
5763
}
5864

endpoints/enchantments/enchantments.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,26 @@ public function __construct(string $pageParam)
3535

3636
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
3737
$this->filter = new EnchantmentListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
38+
if ($this->filter->shouldReload)
39+
{
40+
$_SESSION['error']['fi'] = $this->filter::class;
41+
$get = $this->filter->buildGETParam();
42+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
43+
}
3844
$this->filterError = $this->filter->error;
3945
}
4046

4147
protected function generate() : void
4248
{
4349
$this->h1 = Util::ucFirst(Lang::game('enchantments'));
4450

45-
$this->filter->evalCriteria();
46-
4751
$conditions = [];
48-
4952
if (!User::isInGroup(U_GROUP_EMPLOYEE))
5053
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
5154

5255
if ($_ = $this->filter->getConditions())
5356
$conditions[] = $_;
5457

55-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
56-
5758

5859
/**************/
5960
/* Page Title */

endpoints/guilds/guilds.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public function __construct(string $pageParam)
5353

5454
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
5555
$this->filter = new GuildListFilter($this->_get['filter'] ?? '', ['realms' => $realms]);
56+
if ($this->filter->shouldReload)
57+
{
58+
$_SESSION['error']['fi'] = $this->filter::class;
59+
$get = $this->filter->buildGETParam();
60+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
61+
}
5662
$this->filterError = $this->filter->error;
5763
}
5864

endpoints/icons/icons.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public function __construct(string $pageParam)
3232

3333
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
3434
$this->filter = new IconListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
35+
if ($this->filter->shouldReload)
36+
{
37+
$_SESSION['error']['fi'] = $this->filter::class;
38+
$get = $this->filter->buildGETParam();
39+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
40+
}
3541
$this->filterError = $this->filter->error;
3642
}
3743

@@ -43,13 +49,9 @@ protected function generate() : void
4349
if (!User::isInGroup(U_GROUP_EMPLOYEE))
4450
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
4551

46-
$this->filter->evalCriteria();
47-
4852
if ($_ = $this->filter->getConditions())
4953
$conditions[] = $_;
5054

51-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
52-
5355

5456
/**************/
5557
/* Page Title */

endpoints/items/items.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ public function __construct(string $pageParam)
9999

100100
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
101101
$this->filter = new ItemListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
102+
if ($this->filter->shouldReload)
103+
{
104+
$_SESSION['error']['fi'] = $this->filter::class;
105+
$get = $this->filter->buildGETParam();
106+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
107+
}
102108
$this->filterError = $this->filter->error;
103109
}
104110

@@ -110,14 +116,9 @@ protected function generate() : void
110116
if (!User::isInGroup(U_GROUP_EMPLOYEE))
111117
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
112118

113-
$this->filter->evalCriteria();
114-
$this->filter->evalWeights();
115-
116119
if ($_ = $this->filter->getConditions())
117120
$conditions[] = $_;
118121

119-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
120-
121122

122123
/*******************/
123124
/* evaluate filter */

endpoints/itemsets/itemsets.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public function __construct(string $pageParam)
3232

3333
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
3434
$this->filter = new ItemsetListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
35+
if ($this->filter->shouldReload)
36+
{
37+
$_SESSION['error']['fi'] = $this->filter::class;
38+
$get = $this->filter->buildGETParam();
39+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
40+
}
3541
$this->filterError = $this->filter->error;
3642
}
3743

@@ -43,13 +49,9 @@ protected function generate() : void
4349
if (!User::isInGroup(U_GROUP_EMPLOYEE))
4450
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
4551

46-
$this->filter->evalCriteria();
47-
4852
if ($_ = $this->filter->getConditions())
4953
$conditions[] = $_;
5054

51-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
52-
5355

5456
/*************/
5557
/* Menu Path */

endpoints/npcs/npcs.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public function __construct(string $pageParam)
3535

3636
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
3737
$this->filter = new CreatureListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
38+
if ($this->filter->shouldReload)
39+
{
40+
$_SESSION['error']['fi'] = $this->filter::class;
41+
$get = $this->filter->buildGETParam();
42+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
43+
}
3844
$this->filterError = $this->filter->error;
3945
}
4046

@@ -46,13 +52,9 @@ protected function generate() : void
4652
if (!User::isInGroup(U_GROUP_EMPLOYEE))
4753
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
4854

49-
$this->filter->evalCriteria();
50-
5155
if ($_ = $this->filter->getConditions())
5256
$conditions[] = $_;
5357

54-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
55-
5658
if ($this->category)
5759
{
5860
$conditions[] = ['type', $this->category[0]];

endpoints/objects/objects.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public function __construct(string $pageParam)
3535

3636
$this->subCat = $pageParam !== '' ? '='.$pageParam : '';
3737
$this->filter = new GameObjectListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]);
38+
if ($this->filter->shouldReload)
39+
{
40+
$_SESSION['error']['fi'] = $this->filter::class;
41+
$get = $this->filter->buildGETParam();
42+
$this->forward('?' . $this->pageName . $this->subCat . ($get ? '&filter=' . $get : ''));
43+
}
3844
$this->filterError = $this->filter->error;
3945
}
4046

@@ -46,16 +52,12 @@ protected function generate() : void
4652
if (!User::isInGroup(U_GROUP_EMPLOYEE))
4753
$conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
4854

49-
$this->filter->evalCriteria();
50-
5155
if ($_ = $this->filter->getConditions())
5256
$conditions[] = $_;
5357

5458
if ($this->category)
5559
$conditions[] = ['typeCat', (int)$this->category[0]];
5660

57-
$this->filterError = $this->filter->error; // maybe the evalX() caused something
58-
5961

6062
/*************/
6163
/* Menu Path */

0 commit comments

Comments
 (0)