diff --git a/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php b/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php
index 272a27b4f19..de63ffcad87 100644
--- a/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php
+++ b/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php
@@ -33,6 +33,7 @@ class RegenerateUrlAliasesCommand extends Command
- Take installation offline, during the script execution the database should not be modified.
- Run this command without memory limit, i.e. processing of 300k Locations can take up to 1 GB of RAM.
- Run this command in production environment using --env=prod
+- Manually clear HTTP cache after running this command.
EOT;
/**
@@ -148,6 +149,7 @@ function (Repository $repository) use ($offset, $iterationCount) {
$progressBar->finish();
$output->writeln('');
$output->writeln('Done.');
+ $output->writeln('Make sure to clear HTTP cache afterwards.');
}
/**
diff --git a/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php b/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php
index 5c505700a0b..720240141b6 100644
--- a/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php
+++ b/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php
@@ -34,23 +34,4 @@ public function getMock($originalClassName, $methods = array(), array $arguments
$proxyTarget
);
}
-
- /**
- * Returns a test double for the specified class.
- *
- * @internal Forward compatibility with PHPUnit 5/6, so unit tests written on 6.7 & backported to 5.4 can use this.
- *
- * @param string $originalClassName
- *
- * @return \PHPUnit\Framework\MockObject\MockObject
- */
- protected function createMock($originalClassName)
- {
- return $this->getMockBuilder($originalClassName)
- ->disableOriginalConstructor()
- ->disableOriginalClone()
- ->disableArgumentCloning()
- //->disallowMockingUnknownTypes() Not defined in PHPunit 4.8
- ->getMock();
- }
}
diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
index 85bf00fcb5d..b24cc7d1d3b 100644
--- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
+++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
@@ -936,25 +936,30 @@ private function internalLoadContent(array $contentIds, int $version = null, arr
}
/**
- * @see loadContentInfo(), loadContentInfoByRemoteId(), loadContentInfoList(), loadContentInfoByLocationId()
+ * Get query builder to load Content Info data.
*
- * @param \Doctrine\DBAL\Query\QueryBuilder $query
+ * @see loadContentInfo(), loadContentInfoByRemoteId(), loadContentInfoList(), loadContentInfoByLocationId()
*
- * @return array
+ * @return \Doctrine\DBAL\Query\QueryBuilder
*/
- private function internalLoadContentInfo(DoctrineQueryBuilder $query): array
+ private function createLoadContentInfoQueryBuilder(): DoctrineQueryBuilder
{
- $query
+ $queryBuilder = $this->connection->createQueryBuilder();
+ $expr = $queryBuilder->expr();
+ $queryBuilder
->select('c.*', 't.main_node_id AS ezcontentobject_tree_main_node_id')
->from('ezcontentobject', 'c')
->leftJoin(
'c',
'ezcontentobject_tree',
't',
- 'c.id = t.contentobject_id AND t.node_id = t.main_node_id'
+ $expr->andX(
+ $expr->eq('c.id', 't.contentobject_id'),
+ $expr->eq('t.node_id', 't.main_node_id')
+ )
);
- return $query->execute()->fetchAll();
+ return $queryBuilder;
}
/**
@@ -971,11 +976,12 @@ private function internalLoadContentInfo(DoctrineQueryBuilder $query): array
*/
public function loadContentInfo($contentId)
{
- $query = $this->connection->createQueryBuilder();
- $query->where('c.id = :id')
- ->setParameter('id', $contentId, ParameterType::INTEGER);
+ $queryBuilder = $this->createLoadContentInfoQueryBuilder();
+ $queryBuilder
+ ->where('c.id = :id')
+ ->setParameter('id', $contentId, ParameterType::INTEGER);
- $results = $this->internalLoadContentInfo($query);
+ $results = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE);
if (empty($results)) {
throw new NotFound('content', "id: $contentId");
}
@@ -985,11 +991,12 @@ public function loadContentInfo($contentId)
public function loadContentInfoList(array $contentIds)
{
- $query = $this->connection->createQueryBuilder();
- $query->where('c.id IN (:ids)')
- ->setParameter('ids', $contentIds, Connection::PARAM_INT_ARRAY);
+ $queryBuilder = $this->createLoadContentInfoQueryBuilder();
+ $queryBuilder
+ ->where('c.id IN (:ids)')
+ ->setParameter('ids', $contentIds, Connection::PARAM_INT_ARRAY);
- return $this->internalLoadContentInfo($query);
+ return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE);
}
/**
@@ -1005,11 +1012,12 @@ public function loadContentInfoList(array $contentIds)
*/
public function loadContentInfoByRemoteId($remoteId)
{
- $query = $this->connection->createQueryBuilder();
- $query->where('c.remote_id = :id')
- ->setParameter('id', $remoteId, ParameterType::STRING);
+ $queryBuilder = $this->createLoadContentInfoQueryBuilder();
+ $queryBuilder
+ ->where('c.remote_id = :id')
+ ->setParameter('id', $remoteId, ParameterType::STRING);
- $results = $this->internalLoadContentInfo($query);
+ $results = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE);
if (empty($results)) {
throw new NotFound('content', "remote_id: $remoteId");
}
@@ -1030,11 +1038,12 @@ public function loadContentInfoByRemoteId($remoteId)
*/
public function loadContentInfoByLocationId($locationId)
{
- $query = $this->connection->createQueryBuilder();
- $query->where('t.main_node_id = :id')
- ->setParameter('id', $locationId, ParameterType::INTEGER);
+ $queryBuilder = $this->createLoadContentInfoQueryBuilder();
+ $queryBuilder
+ ->where('t.main_node_id = :id')
+ ->setParameter('id', $locationId, ParameterType::INTEGER);
- $results = $this->internalLoadContentInfo($query);
+ $results = $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE);
if (empty($results)) {
throw new NotFound('content', "main_node_id: $locationId");
}
diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php
index 2ac5edb9e88..97a63c3961c 100644
--- a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php
+++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php
@@ -307,6 +307,10 @@ private function internalPublishUrlAliasForLocation(
* If $languageCode is null the $alias is created in the system's default
* language. $alwaysAvailable makes the alias available in all languages.
*
+ * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
+ * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
+ * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException
+ *
* @param mixed $locationId
* @param string $path
* @param bool $forwarding
@@ -335,6 +339,8 @@ public function createCustomUrlAlias($locationId, $path, $forwarding = false, $l
* language. $alwaysAvailable makes the alias available in all languages.
*
* @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException if the path already exists for the given language
+ * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the path is broken
+ * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
*
* @param string $resource
* @param string $path
@@ -536,9 +542,7 @@ public function removeURLAliases(array $urlAliases)
* Looks up a url alias for the given url.
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
- * @throws \RuntimeException
- * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
- * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
+ * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
*
* @param string $url
diff --git a/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php b/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php
index c827e6c21ea..2efbc22f5be 100644
--- a/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php
+++ b/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php
@@ -69,6 +69,8 @@ public function createGlobalUrlAlias($resource, $path, $forwarding = false, $lan
/**
* List global aliases.
*
+ * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if path for any of the global URL aliases is broken
+ *
* @param string|null $languageCode
* @param int $offset
* @param int $limit
@@ -80,6 +82,8 @@ public function listGlobalURLAliases($languageCode = null, $offset = 0, $limit =
/**
* List of url entries of $urlType, pointing to $locationId.
*
+ * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if any path for the Location is broken
+ *
* @param mixed $locationId
* @param bool $custom if true the user generated aliases are listed otherwise the autogenerated
*
@@ -102,6 +106,8 @@ public function removeURLAliases(array $urlAliases);
* Looks up a url alias for the given url.
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
+ * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
+ * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the stored path for the given URL is broken
*
* @param string $url
*
@@ -112,9 +118,9 @@ public function lookup($url);
/**
* Loads URL alias by given $id.
*
- * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
+ * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if path for the given URL alias is broken
*
- * @param string $id
+ * @param string $id unique identifier in the form of "-"
*
* @return \eZ\Publish\SPI\Persistence\Content\UrlAlias
*/