Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ class Database
protected bool $filter = true;

/**
* @var array<string, bool>|null
* @var array<string, bool>
*/
protected ?array $disabledFilters = [];
protected array $disabledFilters = [];

protected bool $validate = true;

Expand Down Expand Up @@ -8463,22 +8463,16 @@ protected function encodeAttribute(string $name, mixed $value, Document $documen
*/
protected function decodeAttribute(string $filter, mixed $value, Document $document, string $attribute): mixed
{
if (!$this->filter) {
return $value;
}

if (!\is_null($this->disabledFilters) && isset($this->disabledFilters[$filter])) {
return $value;
}
$skip = $this->filter === false || isset($this->disabledFilters[$filter]);

if (!array_key_exists($filter, self::$filters) && !array_key_exists($filter, $this->instanceFilters)) {
throw new NotFoundException("Filter \"{$filter}\" not found for attribute \"{$attribute}\"");
}

if (array_key_exists($filter, $this->instanceFilters)) {
$value = $this->instanceFilters[$filter]['decode']($value, $document, $this);
$value = $this->instanceFilters[$filter]['decode']($value, $document, $this, $skip);
} else {
$value = self::$filters[$filter]['decode']($value, $document, $this);
$value = self::$filters[$filter]['decode']($value, $document, $this, $skip);
}
Comment on lines 8472 to 8476
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Skip logic no longer applied for built-in filters

The $skip flag is now delegated to each filter's decode callback, but none of the built-in filter implementations (json, datetime, point, linestring, polygon, vector, object) accept or inspect this fourth parameter — PHP silently ignores the extra argument. As a result, calling skipFilters(['datetime']) (or disableFilters()) no longer prevents the decode callback from running; the value is still decoded. The previous code returned early before calling the callback at all when $skip was true.

External instance filters registered by callers are affected the same way — they receive an undocumented fourth argument they almost certainly don't handle.


Comment thread
fogelito marked this conversation as resolved.
return $value;
Expand Down