Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

EZP-30136: Updating content with "ezuser" field will not commit changes to Solr #2544

Merged
merged 2 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions eZ/Publish/API/Repository/Tests/SearchEngineIndexingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,38 @@ public function testCreateUser()
$this->assertEquals(1, $result->totalCount);
}

/**
* Test that a newly updated user is available for search.
*/
public function testUpdateUser()
{
$repository = $this->getRepository();
$userService = $repository->getUserService();
$contentService = $repository->getContentService();
$searchService = $repository->getSearchService();

$user = $this->createUserVersion1();

$newName = 'Drizzt Do\'Urden';
$userUpdate = $userService->newUserUpdateStruct();
$userUpdate->contentUpdateStruct = $contentService->newContentUpdateStruct();
$userUpdate->contentUpdateStruct->setField('first_name', $newName);

$userService->updateUser($user, $userUpdate);

$this->refreshSearch($repository);

// Should be found
$query = new Query(
[
'query' => new Criterion\FullText($newName),
]
);
$result = $searchService->findContentInfo($query);

$this->assertEquals(1, $result->totalCount);
}

/**
* Test that a newly created user group is available for search.
*/
Expand Down
48 changes: 48 additions & 0 deletions eZ/Publish/Core/Search/Common/Slot/UpdateUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* This file is part of the eZ Publish Kernel package.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\Search\Common\Slot;

use eZ\Publish\Core\SignalSlot\Signal;
use eZ\Publish\Core\Search\Common\Slot;

/**
* A Search Engine slot handling UpdateUserSignal.
*/
class UpdateUser extends Slot
{
/**
* Receive the given $signal and react on it.
*
* @param \eZ\Publish\Core\SignalSlot\Signal $signal
*/
public function receive(Signal $signal)
{
if (!$signal instanceof Signal\UserService\UpdateUserSignal) {
return;
}

$userContentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo(
$signal->userId
);

$this->searchHandler->indexContent(
$this->persistenceHandler->contentHandler()->load(
$userContentInfo->id,
$userContentInfo->currentVersionNo
)
);

$locations = $this->persistenceHandler->locationHandler()->loadLocationsByContent(
$userContentInfo->id
);
foreach ($locations as $location) {
$this->searchHandler->indexLocation($location);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ parameters:
ezpublish.search.elasticsearch.slot.delete_location.class: eZ\Publish\Core\Search\Common\Slot\DeleteLocation
ezpublish.search.elasticsearch.slot.create_user.class: eZ\Publish\Core\Search\Common\Slot\CreateUser
ezpublish.search.elasticsearch.slot.delete_user.class: eZ\Publish\Core\Search\Common\Slot\DeleteUser
ezpublish.search.elasticsearch.slot.update_user.class: eZ\Publish\Core\Search\Common\Slot\UpdateUser
ezpublish.search.elasticsearch.slot.create_user_group.class: eZ\Publish\Core\Search\Common\Slot\CreateUserGroup
ezpublish.search.elasticsearch.slot.move_user_group.class: eZ\Publish\Core\Search\Common\Slot\MoveUserGroup
ezpublish.search.elasticsearch.slot.delete_user_group.class: eZ\Publish\Core\Search\Common\Slot\DeleteUserGroup
Expand Down Expand Up @@ -87,6 +88,12 @@ services:
tags:
- {name: ezpublish.search.elasticsearch.slot, signal: UserService\DeleteUserSignal}

ezpublish.search.elasticsearch.slot.update_user:
parent: ezpublish.search.elasticsearch.slot
class: "%ezpublish.search.elasticsearch.slot.update_user.class%"
tags:
- {name: ezpublish.search.elasticsearch.slot, signal: UserService\UpdateUserSignal}

ezpublish.search.elasticsearch.slot.create_user_group:
parent: ezpublish.search.elasticsearch.slot
class: "%ezpublish.search.elasticsearch.slot.create_user_group.class%"
Expand Down
7 changes: 7 additions & 0 deletions eZ/Publish/Core/settings/search_engines/legacy/slots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parameters:
ezpublish.search.legacy.slot.assign_section.class: eZ\Publish\Core\Search\Common\Slot\AssignSection
ezpublish.search.legacy.slot.create_user.class: eZ\Publish\Core\Search\Common\Slot\CreateUser
ezpublish.search.legacy.slot.delete_user.class: eZ\Publish\Core\Search\Common\Slot\DeleteUser
ezpublish.search.legacy.slot.update_user.class: eZ\Publish\Core\Search\Common\Slot\UpdateUser
ezpublish.search.legacy.slot.create_user_group.class: eZ\Publish\Core\Search\Common\Slot\CreateUserGroup
ezpublish.search.legacy.slot.delete_user_group.class: eZ\Publish\Core\Search\Common\Slot\DeleteUserGroup

Expand Down Expand Up @@ -89,6 +90,12 @@ services:
tags:
- {name: ezpublish.search.legacy.slot, signal: UserService\DeleteUserSignal}

ezpublish.search.legacy.slot.update_user:
parent: ezpublish.search.legacy.slot
class: "%ezpublish.search.legacy.slot.update_user.class%"
tags:
- {name: ezpublish.search.legacy.slot, signal: UserService\UpdateUserSignal}

ezpublish.search.legacy.slot.create_user_group:
parent: ezpublish.search.legacy.slot
class: "%ezpublish.search.legacy.slot.create_user_group.class%"
Expand Down