Skip to content

Commit 98368a5

Browse files
fix: adjust sorting defaults
1 parent 05267ac commit 98368a5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Endpoint.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ class Endpoint {
334334
public string $sort_order = 'SORT_ASC';
335335

336336
/**
337-
* @var string $sort_flags
337+
* @var string|null $sort_flags
338338
* Sets the default value for the `sort_flags` field in the request data. This value is used to control the sorting
339339
* flags of the Model objects returned by this Endpoint. This value can be overridden by the client in the request
340340
* data. This value only takes effect when the `sort_by` field is also set. This value must be the name of a valid
341341
* PHP sort flags constant (e.g. 'SORT_REGULAR', 'SORT_NATURAL')
342342
*/
343-
public string $sort_flags = 'SORT_REGULAR';
343+
public string|null $sort_flags = null;
344344

345345
/**
346346
* @var bool $append
@@ -1157,7 +1157,7 @@ class Endpoint {
11571157
# Allow the endpoint/client to override the Model's sort_by and sort_order properties
11581158
$this->model->sort_by = $this->sort_by ?? $this->model->sort_by;
11591159
$this->model->sort_order = constant($this->sort_order) ?? $this->model->sort_order;
1160-
$this->model->sort_flags = constant($this->sort_flags) ?? $this->model->sort_flags;
1160+
$this->model->sort_flags = $this->sort_flags ? constant($this->sort_flags) : $this->model->sort_flags;
11611161

11621162
# Create the object and return it
11631163
return $this->model->create(apply: $this->request_data['apply'] === true);
@@ -1181,7 +1181,7 @@ class Endpoint {
11811181
# Allow the endpoint/client to override the Model's sort_by and sort_order properties
11821182
$this->model->sort_by = $this->sort_by ?? $this->model->sort_by;
11831183
$this->model->sort_order = constant($this->sort_order) ?? $this->model->sort_order;
1184-
$this->model->sort_flags = constant($this->sort_flags) ?? $this->model->sort_flags;
1184+
$this->model->sort_flags = $this->sort_flags ? constant($this->sort_flags) : $this->model->sort_flags;
11851185

11861186
# Update the object and return it
11871187
return $this->model->update(

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServerStaticMapping.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class DHCPServerStaticMapping extends Model {
4242
$this->subsystem = 'dhcpd';
4343
$this->many = true;
4444
$this->sort_by = ['ipaddr'];
45+
$this->sort_flags = SORT_NATURAL;
4546

4647
# Define model Fields
4748
$this->mac = new StringField(

0 commit comments

Comments
 (0)