Skip to content

Commit

Permalink
Merge pull request ezsystems#1336 from ezsystems/findContentInfo
Browse files Browse the repository at this point in the history
EZP-24593: Add possibility to search for ContentInfo to avoid Content loading
  • Loading branch information
andrerom committed Jul 30, 2015
2 parents c8024d2 + 4cbefd8 commit fbbf998
Show file tree
Hide file tree
Showing 119 changed files with 752 additions and 574 deletions.
5 changes: 5 additions & 0 deletions doc/bc/changes-5.3.md
Expand Up @@ -160,6 +160,11 @@ Changes affecting version compatibility with former or future versions.
when deleting last version of the Content. Since Content without a version does not make sense, in
this case `eZ\Publish\Core\Repository\ContentService::deleteContent()` should be used instead.


* 5.3.8: $fieldFilters argument on Search service has been renamed to $languageFilter
Reason is to better communicate what the argument is used for. No changes
to it's structure is done so this is a purly cosmetic change.

## Deprecations

* Method `eZ\Publish\API\Repository\RoleService::removePolicy` is deprecated in
Expand Down
13 changes: 13 additions & 0 deletions doc/bc/changes-5.4.md
Expand Up @@ -189,6 +189,19 @@ Changes affecting version compatibility with former or future versions.
when deleting last version of the Content. Since Content without a version does not make sense, in
this case `eZ\Publish\Core\Repository\ContentService::deleteContent()` should be used instead.

* 5.4.5: $fieldFilters argument on Search service has been renamed to $languageFilter
Reason is to better communicate what the argument is used for. No changes
to it's structure is done so this is a purly cosmetic change.

* 5.4.5: $languageFilter specification has changed to work as priority list of languages
To be able to sort on translated values in a predictable way we need to deal with
one language per content object at a time. This change only affects how the sort is
performed internally, and not which fields are returned in the case of findContent.
This furthermore better matches the behaviour of language lists for SiteAccess.
Behaviour of Search engines will be gradually changed to reflect this change, Solr first.
Note: Possibility to search across all languages remains, however Field SortClause will
for instance not work properly in this case, and we plan to start to give warnings about this.

## Deprecations

* `imagemagick` siteaccess settings are now deprecated. It is mandatory to remove them.
Expand Down
37 changes: 27 additions & 10 deletions eZ/Publish/API/Repository/SearchService.php
Expand Up @@ -22,19 +22,38 @@ interface SearchService
/**
* Finds content objects for the given query.
*
* @todo define structs for the field filters
*
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
*
* @param \eZ\Publish\API\Repository\Values\Content\Query $query
* @param array $fieldFilters - a map of filters for the returned fields.
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
* Also used to define which field languages are loaded for the returned content.
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
*
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
*/
public function findContent(Query $query, array $fieldFilters = array(), $filterOnUserPermissions = true);
public function findContent(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true);

/**
* Finds contentInfo objects for the given query.
*
* This method works just like findContent, however does not load the full Content Objects. This means
* it can be more efficient for use cases where you don't need the full Content. Also including use cases
* where content will be loaded by separate code, like an ESI based sub requests that takes content ID as input.
*
* @since 5.4.5
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
*
* @param \eZ\Publish\API\Repository\Values\Content\Query $query
* @param array $languageFilter - a map of filters for the returned fields.
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
* @param bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned.
*
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
*/
public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true);

/**
* Performs a query for a single content object.
Expand All @@ -43,17 +62,15 @@ public function findContent(Query $query, array $fieldFilters = array(), $filter
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if criterion is not valid
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is more than than one result matching the criterions
*
* @todo define structs for the field filters
*
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter
* @param array $fieldFilters - a map of filters for the returned fields.
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
*
* @return \eZ\Publish\API\Repository\Values\Content\Content
*/
public function findSingle(Criterion $filter, array $fieldFilters = array(), $filterOnUserPermissions = true);
public function findSingle(Criterion $filter, array $languageFilter = array(), $filterOnUserPermissions = true);

/**
* Suggests a list of values for the given prefix.
Expand All @@ -71,12 +88,12 @@ public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
*
* @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query
* @param array $fieldFilters - a map of filters for the returned fields.
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
*
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
*/
public function findLocations(LocationQuery $query, array $fieldFilters = array(), $filterOnUserPermissions = true);
public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true);
}
Expand Up @@ -117,7 +117,7 @@ public function testFindSingleThrowsNotFoundException()
/**
* Test for the findContent() method, verifying disabling permissions.
*
* @see \eZ\Publish\API\Repository\ContentService::findContent($query, $fieldFilters, $filterOnUserPermissions)
* @see \eZ\Publish\API\Repository\ContentService::findContent($query, $languageFilter, $filterOnUserPermissions)
* @depends eZ\Publish\API\Repository\Tests\SearchServiceAuthorizationTest::testFindContent
*/
public function testFindContentWithUserPermissionFilter()
Expand Down Expand Up @@ -154,7 +154,7 @@ public function testFindContentWithUserPermissionFilter()
/**
* Test for the findSingle() method disabling permission filtering.
*
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $fieldFilters, $filterOnUserPermissions)
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $languageFilter, $filterOnUserPermissions)
* @depends eZ\Publish\API\Repository\Tests\SearchServiceAuthorizationTest::testFindContent
*/
public function testFindSingleWithUserPermissionFilter()
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testFindSingleWithUserPermissionFilter()
/**
* Test for the findSingle() method.
*
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $fieldFilters, $filterOnUserPermissions)
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $languageFilter, $filterOnUserPermissions)
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @depends eZ\Publish\API\Repository\Tests\SearchServiceAuthorizationTest::testFindContent
*/
Expand Down

0 comments on commit fbbf998

Please sign in to comment.