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);
}

return $value;
Expand Down