Skip to content

Commit

Permalink
SortControl: Call self::handleRequest() in self::apply()
Browse files Browse the repository at this point in the history
If `CompatController::createSortControl()` is not used,
handleRequest may not be called. This is the case for
Icinga DB Web < 1.1 and Icinga Web Graphite integration
<= 1.2.3.

Should be easily reverted.
  • Loading branch information
nilmerg committed Aug 3, 2023
1 parent a857fc6 commit 4239a3d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Control/SortControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ipl\Web\Control;

use GuzzleHttp\Psr7\ServerRequest;
use ipl\Html\Form;
use ipl\Html\FormDecorator\DivDecorator;
use ipl\Html\FormElement\ButtonElement;
Expand Down Expand Up @@ -187,6 +188,12 @@ public function getSort(): ?string
*/
public function apply(Query $query, $defaultSort = null): self
{
if ($this->getRequest() === null) {
// handleRequest() has not been called yet
// TODO: Remove this once everything using this requires ipl v0.12.0
$this->handleRequest(ServerRequest::fromGlobals());
}

$default = $defaultSort ?? (array) $query->getModel()->getDefaultSort();
if (! empty($default)) {
$this->setDefault(SortUtil::normalizeSortSpec($default));
Expand Down

0 comments on commit 4239a3d

Please sign in to comment.