Skip to content

Commit 67f70d5

Browse files
committed
Revert "Lazy search execution"
This reverts commit 95a8e37.
1 parent 95a8e37 commit 67f70d5

9 files changed

+26
-49
lines changed

_test/mock/AggregationEditorTable.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class AggregationEditorTable extends meta\AggregationEditorTable
88
{
99
public function getResult()
1010
{
11-
$this->executeSearch();
1211
return $this->result;
1312
}
1413
}

_test/mock/AggregationTable.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class AggregationTable extends meta\AggregationTable
88
{
99
public function getResult()
1010
{
11-
$this->executeSearch();
1211
return $this->result;
1312
}
1413
}

action/aggregationeditor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ protected function saveRow()
144144
new SearchConfig($config)
145145
);
146146

147-
$editorTable->executeSearch();
148147
echo $editorTable->getFirstRow();
149148
}
150149

meta/Aggregation.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public function __construct($id, $mode, \Doku_Renderer $renderer, SearchConfig $
6060
$this->mode = $mode;
6161
$this->renderer = $renderer;
6262
$this->searchConfig = $searchConfig;
63-
$this->data = $this->searchConfig->getConf();
63+
$this->data = $searchConfig->getConf();
64+
$this->columns = $searchConfig->getColumns();
65+
$this->result = $this->searchConfig->execute();
66+
$this->resultCount = $this->searchConfig->getCount();
6467
$this->helper = plugin_load('helper', 'struct_config');
6568
}
6669

@@ -101,15 +104,6 @@ public function getScopeClasses()
101104
return $classes;
102105
}
103106

104-
public function executeSearch()
105-
{
106-
$this->columns = $this->searchConfig->getColumns();
107-
$this->result = $this->searchConfig->execute();
108-
$this->resultCount = $this->searchConfig->getCount();
109-
110-
$this->postSearch();
111-
}
112-
113107
/**
114108
* Render the actual output to the renderer
115109
*
@@ -126,9 +120,6 @@ abstract public function render($showNotFound = false);
126120
*/
127121
public function startScope()
128122
{
129-
if ($this->mode !== 'metadata') {
130-
$this->executeSearch();
131-
}
132123
if ($this->mode == 'xhtml') {
133124
$classes = $this->getScopeClasses();
134125

@@ -139,16 +130,6 @@ public function startScope()
139130
}
140131
}
141132

142-
/**
143-
* Child classes can set their own class properties based on search result
144-
*
145-
* @return void
146-
*/
147-
public function postSearch()
148-
{
149-
return;
150-
}
151-
152133
/**
153134
* Closes anything opened in startScope()
154135
*

meta/AggregationCloud.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ class AggregationCloud extends Aggregation
2020
* @see render() on the resulting object.
2121
*
2222
*/
23-
public function postSearch()
23+
public function __construct($id, $mode, \Doku_Renderer $renderer, SearchCloud $searchConfig)
2424
{
25+
parent::__construct($id, $mode, $renderer, $searchConfig);
26+
2527
$this->max = $this->result[0]['count'];
2628
$this->min = end($this->result)['count'];
2729
}

meta/AggregationEditorTable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public function render($showNotFound = false)
2727
*/
2828
public function startScope()
2929
{
30-
parent::startScope();
30+
// unique identifier for this aggregation
31+
$hash = md5(var_export($this->data, true));
32+
$this->renderer->info['struct_table_hash'] = $hash;
3133

3234
if ($this->mode != 'xhtml') return;
3335

meta/AggregationList.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,10 @@ class AggregationList extends Aggregation
1212
/** @var int number of all results */
1313
protected $resultColumnCount;
1414

15-
/**
16-
* Set our class property after search has been executed in parent
17-
* @return void
18-
*/
19-
public function startScope()
20-
{
21-
parent::startScope();
22-
}
23-
24-
public function postSearch()
15+
/** @inheritdoc */
16+
public function __construct($id, $mode, \Doku_Renderer $renderer, SearchConfig $searchConfig)
2517
{
18+
parent::__construct($id, $mode, $renderer, $searchConfig);
2619
$this->resultColumnCount = count($this->columns);
2720
}
2821

meta/AggregationTable.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,18 @@ class AggregationTable extends Aggregation
1919
protected $resultRids;
2020
protected $resultRevs;
2121

22+
public function __construct($id, $mode, \Doku_Renderer $renderer, SearchConfig $searchConfig)
23+
{
24+
parent::__construct($id, $mode, $renderer, $searchConfig);
25+
$this->resultPIDs = $this->searchConfig->getPids();
26+
$this->resultRids = $this->searchConfig->getRids();
27+
$this->resultRevs = $this->searchConfig->getRevs();
28+
}
29+
2230
/** @inheritdoc */
2331
public function render($showNotFound = false)
2432
{
33+
2534
// abort early if there are no results at all (not filtered)
2635
if (!$this->resultCount && !$this->isDynamicallyFiltered() && $showNotFound) {
2736
$this->renderer->cdata($this->helper->getLang('none'));
@@ -95,13 +104,6 @@ public function startScope()
95104
parent::startScope();
96105
}
97106

98-
public function postSearch()
99-
{
100-
$this->resultPIDs = $this->searchConfig->getPids();
101-
$this->resultRids = $this->searchConfig->getRids();
102-
$this->resultRevs = $this->searchConfig->getRevs();
103-
}
104-
105107
/**
106108
* Closes the table and anything opened in startScope()
107109
*

syntax/table.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ public function render($format, Doku_Renderer $renderer, $config)
122122
throw new StructException('Aggregation class does not inherit Aggregation: ' . $this->tableclass);
123123
}
124124

125+
$table->startScope();
126+
$table->render(true);
127+
$table->finishScope();
128+
125129
if ($format === 'metadata') {
126130
/** @var Doku_Renderer_metadata $renderer */
127131
$renderer->meta['plugin']['struct']['hasaggregation'] = $search->getCacheFlag();
128-
} else {
129-
$table->startScope();
130-
$table->render(true);
131-
$table->finishScope();
132132
}
133133
} catch (StructException $e) {
134134
msg($e->getMessage(), -1, $e->getLine(), $e->getFile());

0 commit comments

Comments
 (0)