Commit 92166087 authored by bircher's avatar bircher

Issue #3002488 by Grayle, bircher: FilteredStorage::readMultiple needs to filter returned values

parent bf3d227d
......@@ -85,7 +85,7 @@ class FilteredStorage implements FilteredStorageInterface {
$data = $filter->filterReadMultiple($names, $data);
}
ksort($data);
return $data;
return array_filter($data);
}
/**
......
......@@ -174,6 +174,27 @@ class FilteredStorageTest extends CachedStorageTest {
// @codingStandardsIgnoreEnd
}
/**
* Test that when a filter removes config on a readMultiple it is not set.
*/
public function testReadMultipleWithEmptyResults() {
$names = [$this->randomString(), $this->randomString()];
$source = $this->prophesize(StorageInterface::class);
$data = [$this->randomArray(), $this->randomArray()];
$source->readMultiple($names)->willReturn($data);
$source = $source->reveal();
foreach ([0, [], NULL] as $none) {
$filtered = $data;
$filtered[1] = $none;
$filter = $this->prophesizeFilter();
$filter->filterReadMultiple($names, $data)->willReturn($filtered);
$storage = new FilteredStorage($source, [$filter->reveal()]);
$this->assertEquals([$data[0]], $storage->readMultiple($names));
}
}
/**
* Test the write method invokes the filterWrite in filters.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment