From d11e86c400bbc55ccd4619c8995ad7e49a1e0157 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 12:43:03 +0100 Subject: [PATCH 01/19] Added script for fixing var_dir issues for images --- .../LegacyStorage/FixImagesVarDirCommand.php | 355 ++++++++++++++++++ .../EzPublishMigrationExtension.php | 26 ++ .../Resources/config/services.yml | 11 + .../FieldType/Image/ImageStorage/Gateway.php | 28 ++ .../ImageStorage/Gateway/DoctrineStorage.php | 96 +++++ .../ImageStorage/Gateway/LegacyStorage.php | 85 +++++ .../Persistence/Legacy/Content/Gateway.php | 18 + .../Content/Gateway/DoctrineDatabase.php | 48 +++ .../Content/Gateway/ExceptionConversion.php | 36 ++ 9 files changed, 703 insertions(+) create mode 100644 eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php create mode 100644 eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php create mode 100644 eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php new file mode 100644 index 00000000000..30af63b9f63 --- /dev/null +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -0,0 +1,355 @@ +db = $db; + $this->configResolver = $configResolver; + $this->siteaccess = $siteaccess; + $this->contentGateway = $contentGateway; + $this->imageGateway = $imageGateway; + } + + protected function configure() + { + $this + ->setName('ezplatform:fix_images_var_dir') + ->setDescription( + 'This update script will fix references to images that aren\'t part of the current var_dir.' + ) + ->addOption( + 'dry-run', + null, + InputOption::VALUE_NONE, + 'Execute a dry run' + ) + ->addOption( + 'iteration-count', + null, + InputArgument::OPTIONAL, + 'Limit how many records get updated by single process', + self::DEFAULT_ITERATION_COUNT + ) + ->setHelp( + <<%command.name% fixes referefences to images that aren't part of the current var_dir. + +This may for instance occur when the var_dir setting is changed. This script will rename the files, and update the +database references to the new path + +Since this script can potentially run for a very long time, to avoid memory exhaustion run it in +production environment using --env=prod switch. + +EOT + ); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int|void|null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $iterationCount = (int)$input->getOption('iteration-count'); + $this->dryRun = $input->getOption('dry-run'); + $consoleScript = $_SERVER['argv'][0]; + + $this->varDir = $this->configResolver->getParameter( + 'var_dir', + null, + $this->siteaccess->name + ); + + if (getenv('INNER_CALL')) { + $this->processImages($iterationCount, $output); + $output->writeln($this->done); + } else { + $output->writeln([ + sprintf('Fixing image references using siteaccess %s (var_dir: %s)', $this->siteaccess->name, $this->varDir), + 'Calculating number of Images to fix...', + ]); + + $count = $this->countImagesToFix(); + $output->writeln([ + sprintf('Found total of Images for fixing: %d', $count), + '', + ]); + + if ($count == 0) { + $output->writeln('Nothing to process, exiting.'); + + return; + } + + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion( + 'Are you sure you want to proceed? ', + false + ); + + if (!$helper->ask($input, $output, $question)) { + $output->writeln(''); + + return; + } + + $progressBar = $this->getProgressBar($count, $output); + $progressBar->start(); + + for ($fixed = 0; $fixed < $count; $fixed += $iterationCount) { + $processScriptFragments = [ + $this->getPhpPath(), + $consoleScript, + $this->getName(), + '--iteration-count=' . $iterationCount, + '--siteaccess=' . $this->siteaccess->name, + ]; + + $process = new Process( + implode(' ', $processScriptFragments) + ); + + $process->setEnv(['INNER_CALL' => 1]); + $process->run(); + + if (!$process->isSuccessful()) { + throw new RuntimeException($process->getErrorOutput()); + } + + $doneInProcess = (int)$process->getOutput(); + $this->done += $doneInProcess; + $progressBar->advance($doneInProcess); + } + + $progressBar->finish(); + $output->writeln([ + '', + sprintf('Done: %d', $this->done), + ]); + } + } + + /** + * @param int $limit + * @param \Symfony\Component\Console\Output\OutputInterface $output + */ + protected function processImages($limit, OutputInterface $output) + { + $images = $this->getImagesToFix($limit); + + foreach ($images as $image) { + $filePath = $image['filepath']; + $relativePath = substr( + $filePath, + strpos($filePath, self::STORAGE_IMAGES_PATH) + ); + + $newFilePath = $this->varDir . $relativePath; + + if (!$this->dryRun) { + $this->updateImage($image['id'], $image['contentobject_attribute_id'], $filePath, $newFilePath); + } + + ++$this->done; + } + + if (!$this->dryRun) { + $this->updateContentObjectAtributes(); + } + } + + /** + * @param int $imageId + * @param int $contentObjectAttributeId + * @param string $oldFilePath + * @param string $newFilePath + */ + protected function updateImage($imageId, $contentObjectAttributeId, $oldFilePath, $newFilePath) + { + $this->imageGateway->updateImageFilePath($imageId, $newFilePath); + $this->imageAttributes[$contentObjectAttributeId][$oldFilePath] = $newFilePath; + } + + protected function updateContentObjectAtributes() + { + foreach ($this->imageAttributes as $attributeId => $files) { + $attributeObjects = $this->contentGateway->getContentObjectAttributesById($attributeId); + + foreach ($attributeObjects as $attributeObject) { + $dom = new DOMDocument('1.0', 'utf-8'); + + try { + $dom->loadXML(''); + } catch (Exception $e) { + continue; + } + + foreach ($dom->getElementsByTagName('ezimage') as $ezimageNode) { + $oldPath = $ezimageNode->getAttribute('url'); + + if (isset($files[$oldPath])) { + $ezimageNode->setAttribute('url', $files[$oldPath]); + $ezimageNode->setAttribute('dirpath', \dirname($files[$oldPath])); + } + + foreach ($ezimageNode->getElementsByTagName('alias') as $ezimageAlias) { + $oldPath = $ezimageAlias->getAttribute('url'); + if (isset($files[$oldPath])) { + $ezimageAlias->setAttribute('url', $files[$oldPath]); + $ezimageAlias->setAttribute('dirpath', \dirname($files[$oldPath])); + } + } + } + + $this->contentGateway->updateContentObjectAtribute($attributeObject['id'], $attributeObject['version'], $dom->saveXML()); + } + } + } + + /** + * @param int $limit + * + * @return array + */ + protected function getImagesToFix($limit) + { + return $this->imageGateway->getImagesOutsidePath('/' . $this->varDir . '/storage/', $limit, 0); + } + + /** + * @return int + */ + protected function countImagesToFix() + { + return $this->imageGateway->countImageReferencesOutsidePath('/' . $this->varDir . '/storage/'); + } + + /** + * @param int $maxSteps + * @param \Symfony\Component\Console\Output\OutputInterface $output + * + * @return \Symfony\Component\Console\Helper\ProgressBar + */ + protected function getProgressBar($maxSteps, OutputInterface $output) + { + $progressBar = new ProgressBar($output, $maxSteps); + $progressBar->setFormat( + ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%' + ); + + return $progressBar; + } + + /** + * @return string + */ + private function getPhpPath() + { + if ($this->phpPath) { + return $this->phpPath; + } + $phpFinder = new PhpExecutableFinder(); + $this->phpPath = $phpFinder->find(); + if (!$this->phpPath) { + throw new RuntimeException( + 'The php executable could not be found, it\'s needed for executing parable sub processes, so add it to your PATH environment variable and try again' + ); + } + + return $this->phpPath; + } +} diff --git a/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php b/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php new file mode 100644 index 00000000000..f36242ede3b --- /dev/null +++ b/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php @@ -0,0 +1,26 @@ +load('services.yml'); + } +} diff --git a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml new file mode 100644 index 00000000000..3b594fad945 --- /dev/null +++ b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml @@ -0,0 +1,11 @@ +services: + ezpublish.migration.fix_images_var_dir: + class: eZ\Bundle\EzPublishMigrationBundle\Command\LegacyStorage\FixImagesVarDirCommand + arguments: + - "@ezpublish.config.resolver" + - "@ezpublish.api.storage_engine.legacy.dbhandler" + - "@ezpublish.siteaccess" + - "@ezpublish.persistence.legacy.content.gateway" + - "@ezpublish.fieldType.ezimage.storage_gateway" + tags: + - { name: console.command } \ No newline at end of file diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php index 45b8e1ed5ef..647028e9895 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php @@ -61,6 +61,34 @@ abstract public function removeImageReferences($uri, $versionNo, $fieldId); */ abstract public function countImageReferences($uri); + /** + * Returns the number of recorded references outside of the given $path. + * + * @param string $uri File IO uri (not legacy uri) + * + * @return int + */ + abstract public function countImageReferencesOutsidePath($uri); + + /** + * Return references outside of the given $path. + * + * @param string $uri File IO uri (not legacy) + * @param int $limit + * @param int $offset + * + * @return array + */ + abstract public function getImagesOutsidePath($uri, $limit = null, $offset = 0); + + /** + * Updates the filepath of given Image. + * + * @param $imageId + * @param $newFilePath + */ + abstract public function updateImageFilePath($imageId, $newFilePath); + /** * Returns the public uris for the images stored in $xml. */ diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index a4af9f9dc68..1f0558eeed6 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -14,6 +14,7 @@ use eZ\Publish\SPI\Persistence\Content\VersionInfo; use eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway; use PDO; +use function Doctrine\DBAL\Query\QueryBuilder; /** * Image Field Type external storage DoctrineStorage gateway. @@ -225,6 +226,101 @@ public function countImageReferences($uri) return (int) $statement->fetchColumn(); } + /** + * Returns the number of recorded references outside of the given $path. + * + * @param string $uri File IO uri (not legacy) + * + * @return int + */ + public function countImageReferencesOutsidePath($uri) + { + $path = $this->redecorator->redecorateFromSource($uri); + + $selectQuery = $this->connection->createQueryBuilder(); + $selectQuery + ->select('COUNT(' . $this->connection->quoteIdentifier('id') . ')') + ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->where( + $selectQuery->expr()->notLike( + $this->connection->quoteIdentifier('filepath'), + ':likePath' + ) + ) + ->setParameter(':likePath', $path . '%') + ; + + $statement = $selectQuery->execute(); + + return (int) $statement->fetchColumn(); + } + + /** + * Updates the filepath of given Image. + * + * @param $imageId + * @param $newFilePath + */ + public function updateImageFilePath($imageId, $newFilePath) + { + $updateQuery = $this->connection->createQueryBuilder(); + $updateQuery + ->update(self::IMAGE_FILE_TABLE) + ->set( + $this->connection->quoteIdentifier('filepath'), + $updateQuery->expr()->literal($newFilePath) + ) + ->where( + $updateQuery->expr()->eq( + $this->connection->quoteIdentifier('id'), + ':id' + ) + ) + ->setParameter(':id', $imageId) + ; + + $updateQuery->execute(); + } + + /** + * Return references outside of the given $path. + * + * @param string $uri File IO uri (not legacy) + * @param int $limit + * @param int $offset + * + * @return array + */ + public function getImagesOutsidePath($uri, $limit = null, $offset = 0) + { + $path = $this->redecorator->redecorateFromSource($uri); + + $selectQuery = $this->connection->createQueryBuilder(); + $selectQuery->select( + $this->connection->quoteIdentifier('id'), + $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteIdentifier('filepath') + ) + ->from(self::IMAGE_FILE_TABLE) + ->where( + $selectQuery->expr()->notLike( + $this->connection->quoteIdentifier('filepath'), + ':filePath' + ) + ) + ->setParameter(':filePath', $path . '%') + ; + + if ($limit && $offset) { + $selectQuery->setMaxResults($limit); + $selectQuery->setFirstResult($offset); + } + + $statement = $selectQuery->execute(); + + return $statement->fetchAll(\PDO::FETCH_ASSOC); + } + /** * Check if image $path can be removed when deleting $versionNo and $fieldId. * diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php index 0b765daa994..3051859635f 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php @@ -236,6 +236,91 @@ public function countImageReferences($uri) return (int)$statement->fetchColumn(); } + /** + * Returns the number of recorded references outside of the given $path. + * + * @param string $uri File IO uri (not legacy) + * + * @return int + */ + public function countImageReferencesOutsidePath($uri) + { + $path = $this->redecorator->redecorateFromSource($uri); + + $connection = $this->getConnection()->getConnection(); + + $queryBuilder = $connection->createQueryBuilder(); + $statement = $queryBuilder + ->select('count(id)') + ->from('ezimagefile') + ->where('filepath not like :path') + ->setParameter('path', $path . '%') + ->execute(); + + return (int)$statement->fetchColumn(); + } + + /** + * Updates the filepath of given Image. + * + * @param $imageId + * @param $newFilePath + */ + public function updateImageFilePath($imageId, $newFilePath) + { + $connection = $this->getConnection()->getConnection(); + + $query = $connection->createQueryBuilder(); + $query + ->update('ezimagefile') + ->set('filepath', $query->expr()->literal($newFilePath)) + ->where('id = :id') + ->setParameter('id', $imageId); + + $query->execute(); + } + + /** + * Return references outside of the given $path. + * + * @param string $uri File IO uri (not legacy) + * @param int $limit + * @param int $offset + * + * @return array + */ + public function getImagesOutsidePath($uri, $limit = null, $offset = 0) + { + $path = $this->redecorator->redecorateFromSource($uri); + + $connection = $this->getConnection(); + + $selectQuery = $connection->createSelectQuery(); + $selectQuery->select( + $connection->quoteColumn('id'), + $connection->quoteColumn('contentobject_attribute_id'), + $connection->quoteColumn('filepath') + )->from( + $connection->quoteTable('ezimagefile') + )->where( + $selectQuery->expr->not( + $selectQuery->expr->like( + $connection->quoteColumn('filepath'), + $selectQuery->bindValue($path . '%') + ) + ) + ); + + if ($limit && $offset) { + $selectQuery->limit($limit, $offset); + } + + $statement = $selectQuery->prepare(); + $statement->execute(); + + return $statement->fetchAll(\PDO::FETCH_ASSOC); + } + /** * Checks if image $path can be removed when deleting $versionNo and $fieldId. * diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php index 05e0c869032..3d9f4e3fc44 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway.php @@ -429,6 +429,24 @@ abstract public function loadVersionedNameData($rows); */ abstract public function copyRelations($originalContentId, $copiedContentId, $versionNo = null); + /** + * Updates Content's attribute text value. + * + * @param int $attributeId + * @param int $version + * @param string $text + */ + abstract public function updateContentObjectAttributeText($attributeId, $version, $text); + + /** + * Returns an array containing all content attributes with the specified id. + * + * @param int $id + * + * @return array + */ + abstract public function getContentObjectAttributesById($id); + /** * Remove the specified translation from all the Versions of a Content Object. * diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index a9ebf7ff916..1c4e6a37c83 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -2058,6 +2058,54 @@ public function copyRelations($originalContentId, $copiedContentId, $versionNo = $stmt->execute(); } + /** + * Updates Content's attribute text value. + * + * @param int $attributeId + * @param int $version + * @param string $text + */ + public function updateContentObjectAttributeText($attributeId, $version, $text) + { + $query = $this->connection->createQueryBuilder(); + $query + ->update('ezcontentobject_attribute', 'oa') + ->set('oa.data_text', ':text') + ->where('oa.id = :id') + ->andWhere('oa.version = :version') + ->setParameters([ + 'text' => $text, + 'id' => $attributeId, + 'version' => $version, + ], [ + 'text' => PDO::PARAM_STR, + 'id' => PDO::PARAM_INT, + 'version' => PDO::PARAM_INT, + ]); + + $query->execute(); + } + + /** + * Returns an array containing all content attributes with the specified id. + * + * @param int $id + * + * @return array + */ + public function getContentObjectAttributesById($id) + { + $query = $this->connection->createQueryBuilder(); + $query + ->select('oa.data_text, oa.id, oa.version') + ->from('ezcontentobject_attribute', 'oa') + ->where('oa.id = :id') + ->setParameter('id', $id, PDO::PARAM_INT); + $statement = $query->execute(); + + return $statement->fetchAll(PDO::FETCH_ASSOC); + } + /** * Remove the specified translation from the Content Object Version. * diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php index 0574d852e8e..552a52ed5bb 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php @@ -823,4 +823,40 @@ public function deleteTranslationFromVersion($contentId, $versionNo, $languageCo throw new RuntimeException('Database error', 0, $e); } } + + /** + * Updates Content's attribute text value. + * + * @param int $attributeId + * @param int $version + * @param string $text + */ + public function updateContentObjectAttributeText($attributeId, $version, $text) + { + try { + return $this->innerGateway->updateContentObjectAttributeText($attributeId, $version, $text); + } catch (DBALException $e) { + throw new RuntimeException('Database error', 0, $e); + } catch (PDOException $e) { + throw new RuntimeException('Database error', 0, $e); + } + } + + /** + * Returns an array containing all content attributes with the specified id. + * + * @param int $id + * + * @return array + */ + public function getContentObjectAttributesById($id) + { + try { + return $this->innerGateway->getContentObjectAttributesById($id); + } catch (DBALException $e) { + throw new RuntimeException('Database error', 0, $e); + } catch (PDOException $e) { + throw new RuntimeException('Database error', 0, $e); + } + } } From 981dd99aab80db5349d098e6e21c358e69728157 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 13:27:04 +0100 Subject: [PATCH 02/19] CS fixup --- .../Image/ImageStorage/Gateway/DoctrineStorage.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index 1f0558eeed6..404a1b86253 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -10,11 +10,10 @@ use Doctrine\DBAL\Connection; use DOMDocument; +use eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway; use eZ\Publish\Core\IO\UrlRedecoratorInterface; use eZ\Publish\SPI\Persistence\Content\VersionInfo; -use eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway; use PDO; -use function Doctrine\DBAL\Query\QueryBuilder; /** * Image Field Type external storage DoctrineStorage gateway. @@ -55,8 +54,6 @@ public function __construct(UrlRedecoratorInterface $redecorator, Connection $co /** * Return the node path string of $versionInfo. * - * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo - * * @return string */ public function getNodePathString(VersionInfo $versionInfo) @@ -121,7 +118,6 @@ public function storeImageReference($uri, $fieldId) * Return an XML content stored for the given $fieldIds. * * @param int $versionNo - * @param array $fieldIds * * @return array */ From f0c36a90a69b11600e4b7e99c7dd7c28a43eeb08 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:15:48 +0100 Subject: [PATCH 03/19] Update eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index 30af63b9f63..bc5976e5cad 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -108,7 +108,7 @@ protected function configure() $this ->setName('ezplatform:fix_images_var_dir') ->setDescription( - 'This update script will fix references to images that aren\'t part of the current var_dir.' + 'This update script will fix references to images that are not placed in the current var_dir.' ) ->addOption( 'dry-run', From 4622abbf1171a734b4bb218cc59e4b3b7eabdeba Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:16:03 +0100 Subject: [PATCH 04/19] Update eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index bc5976e5cad..da8e8478b8a 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -125,7 +125,7 @@ protected function configure() ) ->setHelp( <<%command.name% fixes referefences to images that aren't part of the current var_dir. +The command %command.name% fixes references to images that are not placed in the current var_dir. This may for instance occur when the var_dir setting is changed. This script will rename the files, and update the database references to the new path From 3a8ec28a5b3050252144cd63045f607c772a9ac2 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:16:11 +0100 Subject: [PATCH 05/19] Update eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../EzPublishMigrationBundle/Resources/config/services.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml index 3b594fad945..d464dcab8bc 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml +++ b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml @@ -8,4 +8,5 @@ services: - "@ezpublish.persistence.legacy.content.gateway" - "@ezpublish.fieldType.ezimage.storage_gateway" tags: - - { name: console.command } \ No newline at end of file + - { name: console.command } + From 32726245e79e57a01cfacc4679b6f20b53eb36ee Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:16:53 +0100 Subject: [PATCH 06/19] Update eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php index 647028e9895..5c0b09bd304 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway.php @@ -71,7 +71,7 @@ abstract public function countImageReferences($uri); abstract public function countImageReferencesOutsidePath($uri); /** - * Return references outside of the given $path. + * Returns references outside of the given $path. * * @param string $uri File IO uri (not legacy) * @param int $limit From 6543f9cd489b3eaaadd723253868d9666e50bf98 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:21:07 +0100 Subject: [PATCH 07/19] Update eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index da8e8478b8a..2715edd2697 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -144,7 +144,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $iterationCount = (int)$input->getOption('iteration-count'); + $iterationCount = (int) $input->getOption('iteration-count'); $this->dryRun = $input->getOption('dry-run'); $consoleScript = $_SERVER['argv'][0]; From 16bb1da96f7a27b144f8513b6cb9983796512072 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:21:24 +0100 Subject: [PATCH 08/19] Update eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php index 3051859635f..b528ad7551f 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php @@ -301,7 +301,7 @@ public function getImagesOutsidePath($uri, $limit = null, $offset = 0) $connection->quoteColumn('contentobject_attribute_id'), $connection->quoteColumn('filepath') )->from( - $connection->quoteTable('ezimagefile') + $connection->quoteTable(self::IMAGE_FILE_TABLE) )->where( $selectQuery->expr->not( $selectQuery->expr->like( From 6a7f71cc5965abd1569a11b0f4d3d59cd8592b9e Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:27:20 +0100 Subject: [PATCH 09/19] Update eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php index b528ad7551f..2613cbbd858 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php @@ -264,7 +264,7 @@ public function countImageReferencesOutsidePath($uri) * Updates the filepath of given Image. * * @param $imageId - * @param $newFilePath + * @param string $newFilePath */ public function updateImageFilePath($imageId, $newFilePath) { From e677e6b5363cb7f4ee0c91c3b31fdde37f6bd500 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Wed, 18 Mar 2020 14:30:27 +0100 Subject: [PATCH 10/19] Reverted changes to LegacyStorage as it is deprecated since 6.11 --- .../ImageStorage/Gateway/LegacyStorage.php | 85 ------------------- 1 file changed, 85 deletions(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php index 2613cbbd858..0b765daa994 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/LegacyStorage.php @@ -236,91 +236,6 @@ public function countImageReferences($uri) return (int)$statement->fetchColumn(); } - /** - * Returns the number of recorded references outside of the given $path. - * - * @param string $uri File IO uri (not legacy) - * - * @return int - */ - public function countImageReferencesOutsidePath($uri) - { - $path = $this->redecorator->redecorateFromSource($uri); - - $connection = $this->getConnection()->getConnection(); - - $queryBuilder = $connection->createQueryBuilder(); - $statement = $queryBuilder - ->select('count(id)') - ->from('ezimagefile') - ->where('filepath not like :path') - ->setParameter('path', $path . '%') - ->execute(); - - return (int)$statement->fetchColumn(); - } - - /** - * Updates the filepath of given Image. - * - * @param $imageId - * @param string $newFilePath - */ - public function updateImageFilePath($imageId, $newFilePath) - { - $connection = $this->getConnection()->getConnection(); - - $query = $connection->createQueryBuilder(); - $query - ->update('ezimagefile') - ->set('filepath', $query->expr()->literal($newFilePath)) - ->where('id = :id') - ->setParameter('id', $imageId); - - $query->execute(); - } - - /** - * Return references outside of the given $path. - * - * @param string $uri File IO uri (not legacy) - * @param int $limit - * @param int $offset - * - * @return array - */ - public function getImagesOutsidePath($uri, $limit = null, $offset = 0) - { - $path = $this->redecorator->redecorateFromSource($uri); - - $connection = $this->getConnection(); - - $selectQuery = $connection->createSelectQuery(); - $selectQuery->select( - $connection->quoteColumn('id'), - $connection->quoteColumn('contentobject_attribute_id'), - $connection->quoteColumn('filepath') - )->from( - $connection->quoteTable(self::IMAGE_FILE_TABLE) - )->where( - $selectQuery->expr->not( - $selectQuery->expr->like( - $connection->quoteColumn('filepath'), - $selectQuery->bindValue($path . '%') - ) - ) - ); - - if ($limit && $offset) { - $selectQuery->limit($limit, $offset); - } - - $statement = $selectQuery->prepare(); - $statement->execute(); - - return $statement->fetchAll(\PDO::FETCH_ASSOC); - } - /** * Checks if image $path can be removed when deleting $versionNo and $fieldId. * From 2f401ed7496c74924b96c74128df4b589cbed591 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 10:03:03 +0200 Subject: [PATCH 11/19] Update eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml Co-Authored-By: Andrew Longosz --- .../Resources/config/services.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml index d464dcab8bc..abeb7506d30 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml +++ b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml @@ -2,11 +2,11 @@ services: ezpublish.migration.fix_images_var_dir: class: eZ\Bundle\EzPublishMigrationBundle\Command\LegacyStorage\FixImagesVarDirCommand arguments: - - "@ezpublish.config.resolver" - - "@ezpublish.api.storage_engine.legacy.dbhandler" - - "@ezpublish.siteaccess" - - "@ezpublish.persistence.legacy.content.gateway" - - "@ezpublish.fieldType.ezimage.storage_gateway" + - '@ezpublish.config.resolver' + - '@ezpublish.api.storage_engine.legacy.dbhandler' + - '@ezpublish.siteaccess' + - '@ezpublish.persistence.legacy.content.gateway' + - '@ezpublish.fieldType.ezimage.storage_gateway' tags: - { name: console.command } From f28c7c22edaadaa7cf9372e7051150629e20ba5c Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 10:03:52 +0200 Subject: [PATCH 12/19] Update eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php Co-Authored-By: Andrew Longosz --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index 2715edd2697..a5deb34140e 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -140,7 +140,7 @@ protected function configure() /** * @param InputInterface $input * @param OutputInterface $output - * @return int|void|null + * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { From 44e352525e276e09b267d3fba5323e1041068ac9 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 10:13:13 +0200 Subject: [PATCH 13/19] Update eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php Co-Authored-By: Andrew Longosz --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index a5deb34140e..57f3f192220 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -1,8 +1,6 @@ Date: Thu, 2 Apr 2020 10:48:51 +0200 Subject: [PATCH 14/19] Update eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php Co-Authored-By: Andrew Longosz --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index 57f3f192220..ab0f8503e03 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -79,13 +79,6 @@ class FixImagesVarDirCommand extends Command */ private $imageAttributes = []; - /** - * @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ChainConfigResolver; $configResolver - * @param \eZ\Publish\Core\Persistence\Database\DatabaseHandler $db - * @param \eZ\Publish\Core\MVC\Symfony\SiteAccess $siteaccess - * @param \eZ\Publish\Core\Persistence\Legacy\Content\Gateway $contentGateway - * @param \eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway $imageGateway - */ public function __construct( ChainConfigResolver $configResolver, DatabaseHandler $db, From 2923b6c1c3281765938b0bdcc983d5df5905956f Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 11:07:27 +0200 Subject: [PATCH 15/19] Update eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index 404a1b86253..dd79b054e32 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -254,7 +254,7 @@ public function countImageReferencesOutsidePath($uri) /** * Updates the filepath of given Image. * - * @param $imageId + * @param int $imageId * @param $newFilePath */ public function updateImageFilePath($imageId, $newFilePath) From 9bed9cfb486b38ddf8a144484fda0fd0de85b40e Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 11:22:28 +0200 Subject: [PATCH 16/19] Update eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php Co-Authored-By: Andrew Longosz --- .../DependencyInjection/EzPublishMigrationExtension.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php b/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php index f36242ede3b..487a7edcec9 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php +++ b/eZ/Bundle/EzPublishMigrationBundle/DependencyInjection/EzPublishMigrationExtension.php @@ -1,8 +1,6 @@ Date: Thu, 2 Apr 2020 11:23:18 +0200 Subject: [PATCH 17/19] Update eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php Co-Authored-By: Konrad Oboza <34310128+konradoboza@users.noreply.github.com> --- .../FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index dd79b054e32..92b6d6139f0 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -255,7 +255,7 @@ public function countImageReferencesOutsidePath($uri) * Updates the filepath of given Image. * * @param int $imageId - * @param $newFilePath + * @param string $newFilePath */ public function updateImageFilePath($imageId, $newFilePath) { From 1baa65e62034754522cd44ef58111267cf76d436 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 11:24:31 +0200 Subject: [PATCH 18/19] Update eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php Co-Authored-By: Andrew Longosz --- .../Persistence/Legacy/Content/Gateway/DoctrineDatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index 1c4e6a37c83..0ae058ff6fe 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -2070,7 +2070,7 @@ public function updateContentObjectAttributeText($attributeId, $version, $text) $query = $this->connection->createQueryBuilder(); $query ->update('ezcontentobject_attribute', 'oa') - ->set('oa.data_text', ':text') + ->set('data_text', ':text') ->where('oa.id = :id') ->andWhere('oa.version = :version') ->setParameters([ From 5cca5be10d571fbb3cbfa5bf875aa8762afda651 Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek Date: Thu, 2 Apr 2020 11:26:50 +0200 Subject: [PATCH 19/19] CR fixups --- .../Command/LegacyStorage/FixImagesVarDirCommand.php | 11 ++++------- .../Resources/config/services.yml | 1 - .../Image/ImageStorage/Gateway/DoctrineStorage.php | 5 ++++- .../Legacy/Content/Gateway/ExceptionConversion.php | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php index ab0f8503e03..b362ac5cb7f 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php +++ b/eZ/Bundle/EzPublishMigrationBundle/Command/LegacyStorage/FixImagesVarDirCommand.php @@ -81,13 +81,11 @@ class FixImagesVarDirCommand extends Command public function __construct( ChainConfigResolver $configResolver, - DatabaseHandler $db, SiteAccess $siteaccess, ContentGateway $contentGateway, ImageGateway $imageGateway ) { parent::__construct(); - $this->db = $db; $this->configResolver = $configResolver; $this->siteaccess = $siteaccess; $this->contentGateway = $contentGateway; @@ -99,7 +97,7 @@ protected function configure() $this ->setName('ezplatform:fix_images_var_dir') ->setDescription( - 'This update script will fix references to images that are not placed in the current var_dir.' + 'This update script will fix database references to images that are not placed in the current var_dir.' ) ->addOption( 'dry-run', @@ -116,13 +114,12 @@ protected function configure() ) ->setHelp( <<%command.name% fixes references to images that are not placed in the current var_dir. +The command %command.name% fixes database references to images that are not placed in the current var_dir. -This may for instance occur when the var_dir setting is changed. This script will rename the files, and update the -database references to the new path +This may for instance occur when the var_dir setting is changed. This script will update the database references to the new path Since this script can potentially run for a very long time, to avoid memory exhaustion run it in -production environment using --env=prod switch. +production environment using --env=prod switch and with --no-debug for non-prod environments. EOT ); diff --git a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml index abeb7506d30..19cf7bc5de2 100644 --- a/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml +++ b/eZ/Bundle/EzPublishMigrationBundle/Resources/config/services.yml @@ -3,7 +3,6 @@ services: class: eZ\Bundle\EzPublishMigrationBundle\Command\LegacyStorage\FixImagesVarDirCommand arguments: - '@ezpublish.config.resolver' - - '@ezpublish.api.storage_engine.legacy.dbhandler' - '@ezpublish.siteaccess' - '@ezpublish.persistence.legacy.content.gateway' - '@ezpublish.fieldType.ezimage.storage_gateway' diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index 92b6d6139f0..d57e218e1b8 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -54,6 +54,8 @@ public function __construct(UrlRedecoratorInterface $redecorator, Connection $co /** * Return the node path string of $versionInfo. * + * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo + * * @return string */ public function getNodePathString(VersionInfo $versionInfo) @@ -118,6 +120,7 @@ public function storeImageReference($uri, $fieldId) * Return an XML content stored for the given $fieldIds. * * @param int $versionNo + * @param array $fieldIds * * @return array */ @@ -307,7 +310,7 @@ public function getImagesOutsidePath($uri, $limit = null, $offset = 0) ->setParameter(':filePath', $path . '%') ; - if ($limit && $offset) { + if ($limit !== null) { $selectQuery->setMaxResults($limit); $selectQuery->setFirstResult($offset); } diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php index 552a52ed5bb..54691192cc9 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/ExceptionConversion.php @@ -834,7 +834,7 @@ public function deleteTranslationFromVersion($contentId, $versionNo, $languageCo public function updateContentObjectAttributeText($attributeId, $version, $text) { try { - return $this->innerGateway->updateContentObjectAttributeText($attributeId, $version, $text); + $this->innerGateway->updateContentObjectAttributeText($attributeId, $version, $text); } catch (DBALException $e) { throw new RuntimeException('Database error', 0, $e); } catch (PDOException $e) {