Skip to content

Commit

Permalink
Merge remote-tracking branch 'ezsystems/7.5' into 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Mar 18, 2022
2 parents 2de8ac5 + 6aa912e commit ca23200
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ static function (array $data) use ($filePath) {

private function getImagePathsToNormalize(SymfonyStyle $io): array
{
$imagesCount = $this->imageGateway->countDistinctImages();
$imagesDataCount = $this->imageGateway->countDistinctImagesData();
$imagePathsToNormalize = [];
$iterations = ceil($imagesCount / self::IMAGE_LIMIT);
$io->progressStart($imagesCount);
$iterations = ceil($imagesDataCount / self::IMAGE_LIMIT);
$io->progressStart($imagesDataCount);
for ($i = 0; $i < $iterations; ++$i) {
$imagesData = $this->imageGateway->getImagesData(
$i * self::IMAGE_LIMIT,
Expand Down
2 changes: 2 additions & 0 deletions eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ abstract public function updateImageData(int $fieldId, int $versionNo, string $x
abstract public function getImagesData(int $offset, int $limit): array;

abstract public function updateImagePath(int $fieldId, string $oldPath, string $newPath): void;

abstract public function countDistinctImagesData(): int;
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,17 @@ public function isImageReferenced(string $uri): bool
return (bool)$statement->fetchOne();
}

public function countDistinctImages(): int
public function countDistinctImagesData(): int
{
$selectQuery = $this->connection->createQueryBuilder();
$selectQuery
->select($this->connection->getDatabasePlatform()->getCountExpression('DISTINCT(filepath)'))
->select($this->connection->getDatabasePlatform()->getCountExpression('id'))
->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE))
;

$statement = $selectQuery->execute();

return (int) $statement->fetchColumn();
return (int) $statement->fetchOne();
}

/**
Expand Down

0 comments on commit ca23200

Please sign in to comment.