Search API should have a way of filtering blocked users out of the index for sites like mine that do not delete user account information but instead set the account to inactive (blocked). In many use cases, it could be problematic if data from user accounts that had been blocked was somehow accidentally exposed in the index, so there should be an option by default to prevent such accounts from being index.

Patch coming soon.

Comments

ptmkenny’s picture

Here's a patch to add this feature.

ptmkenny’s picture

Status: Active » Needs review
drunken monkey’s picture

Good idea, thanks for the patch!
Seems small and simple enough to not cause any trouble, I'd say. I just have some corrections for the doc comments and the description (we should included the same warning as for the "Exclude unpublished nodes" alteration, I'd say). See the attachments.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.
Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

drunken monkey’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

Ah, forgot that this of course also needs to be ported …

drunken monkey’s picture

Issue tags: +Release blocker, +Novice

Pretty easy, I'd say, but would be a (slight) regression if we didn't have it in the first stable release.

Also, instead of porting the processor, we might just want to expand/rename the existing "Node status" processor to cover users, too (and maybe other entity types).

drunken monkey’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new12.79 KB

Took my suggestion from #8. The new "Entity status" processor supports nodes, comments and users, and also has better test coverage than the old "Node status" processor.
An update function is included, too, of course, to switch to the new processor. I guess we should also warn about that in the release notes. The update function, once again, does not have test coverage, though. I'd need a good example for how to do that.

Status: Needs review » Needs work

The last submitted patch, 9: 2491175-9--entity_status_processor.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new3.05 KB
new15.13 KB

Ah, yes, forgot a few things.

Status: Needs review » Needs work

The last submitted patch, 11: 2491175-11--entity_status_processor.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 11: 2491175-11--entity_status_processor.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new15.19 KB

Re-roll.

borisson_’s picture

Status: Needs review » Needs work

Only nits to pick.

  1. +++ b/search_api.install
    @@ -200,3 +200,28 @@ function search_api_update_8102() {
    +      // Mark the resulting configuration as trusted data. This avoids issues
    +      // with future schema changes.
    

    Where does that happen?

  2. +++ b/src/Plugin/search_api/processor/EntityStatus.php
    @@ -2,30 +2,33 @@
    +    $supported_entity_types = ['node', 'comment', 'user'];
    ...
    -      if ($datasource->getEntityTypeId() == 'node') {
    +      if (in_array($datasource->getEntityTypeId(), $supported_entity_types)) {
    

    Can we add the comment here about EntityPublishedInterface as well?

  3. +++ b/tests/src/Unit/Plugin/Processor/EntityStatusTest.php
    @@ -0,0 +1,156 @@
    +      'multiple datasources' => [NULL, TRUE],
    

    /s/multiple/all/ ?

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new690 bytes
new15.18 KB

Where does that happen?

In the next line, by passing TRUE to save().
I just stole the code from some Core update function, probably Block or Views, and that had the same comment (and parameter). Pretty important to include, actually, I guess.

Can we add the comment here about EntityPublishedInterface as well?

I don't see how it would apply there? While it is possible to extract the entity class and check whether it implements EntityPublishedInterface, I really don't think that's worth it. (Also, this only applies to nodes and comments, so we'd have to hard-code users anyways.)
In alterIndexedItems() it would just allow us to combine the two if blocks for nodes and comments, that's all – a pretty trivial change. Using it in supportsIndex(), too, would be a significantly larger change, that would have to be its own feature request (in case someone wants support for another content entity type that implements that interface).

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Ah, thanks for explaining.

  • drunken monkey committed 32db502 on 8.x-1.x
    Issue #2491175 by drunken monkey, ptmkenny: Added a new "Entity status"...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again for your input!
Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.