Skip to content

Commit fbbf998

Browse files
committed
Merge pull request #1336 from ezsystems/findContentInfo
EZP-24593: Add possibility to search for ContentInfo to avoid Content loading
2 parents c8024d2 + 4cbefd8 commit fbbf998

File tree

119 files changed

+752
-574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+752
-574
lines changed

doc/bc/changes-5.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ Changes affecting version compatibility with former or future versions.
160160
when deleting last version of the Content. Since Content without a version does not make sense, in
161161
this case `eZ\Publish\Core\Repository\ContentService::deleteContent()` should be used instead.
162162

163+
164+
* 5.3.8: $fieldFilters argument on Search service has been renamed to $languageFilter
165+
Reason is to better communicate what the argument is used for. No changes
166+
to it's structure is done so this is a purly cosmetic change.
167+
163168
## Deprecations
164169

165170
* Method `eZ\Publish\API\Repository\RoleService::removePolicy` is deprecated in

doc/bc/changes-5.4.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ Changes affecting version compatibility with former or future versions.
189189
when deleting last version of the Content. Since Content without a version does not make sense, in
190190
this case `eZ\Publish\Core\Repository\ContentService::deleteContent()` should be used instead.
191191

192+
* 5.4.5: $fieldFilters argument on Search service has been renamed to $languageFilter
193+
Reason is to better communicate what the argument is used for. No changes
194+
to it's structure is done so this is a purly cosmetic change.
195+
196+
* 5.4.5: $languageFilter specification has changed to work as priority list of languages
197+
To be able to sort on translated values in a predictable way we need to deal with
198+
one language per content object at a time. This change only affects how the sort is
199+
performed internally, and not which fields are returned in the case of findContent.
200+
This furthermore better matches the behaviour of language lists for SiteAccess.
201+
Behaviour of Search engines will be gradually changed to reflect this change, Solr first.
202+
Note: Possibility to search across all languages remains, however Field SortClause will
203+
for instance not work properly in this case, and we plan to start to give warnings about this.
204+
192205
## Deprecations
193206

194207
* `imagemagick` siteaccess settings are now deprecated. It is mandatory to remove them.

eZ/Publish/API/Repository/SearchService.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,38 @@ interface SearchService
2222
/**
2323
* Finds content objects for the given query.
2424
*
25-
* @todo define structs for the field filters
26-
*
2725
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
2826
*
2927
* @param \eZ\Publish\API\Repository\Values\Content\Query $query
30-
* @param array $fieldFilters - a map of filters for the returned fields.
28+
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
29+
* Also used to define which field languages are loaded for the returned content.
3130
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
3231
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
3332
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
3433
*
3534
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
3635
*/
37-
public function findContent(Query $query, array $fieldFilters = array(), $filterOnUserPermissions = true);
36+
public function findContent(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true);
37+
38+
/**
39+
* Finds contentInfo objects for the given query.
40+
*
41+
* This method works just like findContent, however does not load the full Content Objects. This means
42+
* it can be more efficient for use cases where you don't need the full Content. Also including use cases
43+
* where content will be loaded by separate code, like an ESI based sub requests that takes content ID as input.
44+
*
45+
* @since 5.4.5
46+
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
47+
*
48+
* @param \eZ\Publish\API\Repository\Values\Content\Query $query
49+
* @param array $languageFilter - a map of filters for the returned fields.
50+
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
51+
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
52+
* @param bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned.
53+
*
54+
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
55+
*/
56+
public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true);
3857

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

5875
/**
5976
* Suggests a list of values for the given prefix.
@@ -71,12 +88,12 @@ public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $
7188
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
7289
*
7390
* @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query
74-
* @param array $fieldFilters - a map of filters for the returned fields.
91+
* @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
7592
* Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
7693
* useAlwaysAvailable defaults to true to avoid exceptions on missing translations
7794
* @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
7895
*
7996
* @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
8097
*/
81-
public function findLocations(LocationQuery $query, array $fieldFilters = array(), $filterOnUserPermissions = true);
98+
public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true);
8299
}

eZ/Publish/API/Repository/Tests/SearchServiceAuthorizationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function testFindSingleThrowsNotFoundException()
117117
/**
118118
* Test for the findContent() method, verifying disabling permissions.
119119
*
120-
* @see \eZ\Publish\API\Repository\ContentService::findContent($query, $fieldFilters, $filterOnUserPermissions)
120+
* @see \eZ\Publish\API\Repository\ContentService::findContent($query, $languageFilter, $filterOnUserPermissions)
121121
* @depends eZ\Publish\API\Repository\Tests\SearchServiceAuthorizationTest::testFindContent
122122
*/
123123
public function testFindContentWithUserPermissionFilter()
@@ -154,7 +154,7 @@ public function testFindContentWithUserPermissionFilter()
154154
/**
155155
* Test for the findSingle() method disabling permission filtering.
156156
*
157-
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $fieldFilters, $filterOnUserPermissions)
157+
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $languageFilter, $filterOnUserPermissions)
158158
* @depends eZ\Publish\API\Repository\Tests\SearchServiceAuthorizationTest::testFindContent
159159
*/
160160
public function testFindSingleWithUserPermissionFilter()
@@ -184,7 +184,7 @@ public function testFindSingleWithUserPermissionFilter()
184184
/**
185185
* Test for the findSingle() method.
186186
*
187-
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $fieldFilters, $filterOnUserPermissions)
187+
* @see \eZ\Publish\API\Repository\ContentService::findSingle($query, $languageFilter, $filterOnUserPermissions)
188188
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException
189189
* @depends eZ\Publish\API\Repository\Tests\SearchServiceAuthorizationTest::testFindContent
190190
*/

0 commit comments

Comments
 (0)