mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 01:19:44 +01:00
Add a version filter to e_file_inspector::getPathIterator()
This commit is contained in:
parent
0494000356
commit
bb1c32489c
@ -48,9 +48,10 @@ interface e_file_inspector_interface
|
||||
/**
|
||||
* Return an Iterator that can enumerate every path in the image database
|
||||
*
|
||||
* @param $version string|null Provide a PHP-standardized version to limit the paths to that version
|
||||
* @return Iterator
|
||||
*/
|
||||
public function getPathIterator();
|
||||
public function getPathIterator($version = null);
|
||||
|
||||
/**
|
||||
* Get all the known file integrity hashes for the provided path
|
||||
|
@ -31,11 +31,24 @@ class e_file_inspector_sqlphar extends e_file_inspector
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getPathIterator()
|
||||
public function getPathIterator($version = null)
|
||||
{
|
||||
$statement = $this->coreImage->query(
|
||||
"SELECT path FROM file_hashes ORDER BY path ASC;"
|
||||
);
|
||||
$addVersionWhere = "";
|
||||
$inputParameters = [];
|
||||
if (!empty($version))
|
||||
{
|
||||
$addVersionWhere = "WHERE versions.version_string = ?";
|
||||
$inputParameters[] = $version;
|
||||
}
|
||||
$statement = $this->coreImage->prepare("
|
||||
SELECT path
|
||||
FROM file_hashes
|
||||
LEFT JOIN versions ON versions.version_id = file_hashes.release_version
|
||||
$addVersionWhere
|
||||
ORDER BY path ASC;
|
||||
");
|
||||
$statement->setFetchMode(PDO::FETCH_COLUMN, 0);
|
||||
$statement->execute($inputParameters);
|
||||
return new IteratorIterator($statement);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,15 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
|
||||
$this->assertNotEmpty($actualVersion);
|
||||
}
|
||||
|
||||
public function testGetPathIterator()
|
||||
{
|
||||
$iterator = $this->e_integrity->getPathIterator();
|
||||
$this->assertGreaterThanOrEqual(1, iterator_count($iterator));
|
||||
|
||||
$iterator = $this->e_integrity->getPathIterator("0.0.1-fakeNonExistentVersion");
|
||||
$this->assertEquals(0, iterator_count($iterator));
|
||||
}
|
||||
|
||||
public function testValidate()
|
||||
{
|
||||
$result = $this->e_integrity->validate("index.php");
|
||||
|
Loading…
x
Reference in New Issue
Block a user