Tested with 8.1.0-beta3 on a fresh install of Drupal 8.2.2

- Enable Search API, Database search, and Database Search Defaults
- Disable Database Search Defaults
- Go to admin/config/search/search-api/index/default_index/fields
- Click "Save changes"

Results in error:

search_api_node_grants is a reserved value and cannot be used as the machine name of a normal field

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mike Chelen created an issue. See original summary.

claudiu.cristea’s picture

Priority: Major » Critical

I confirm this bug with latest from HEAD (895b50787d54cd3f6bc3f8d4833cec809a8d021d). And this is critical because it prevents saving the fields form.

drunken monkey’s picture

Thanks for reporting! As you say, this problem is pretty bad.
I tried disabling the "Content access" processor shortly to fix it, but this just causes a different fatal error (#2761719: Removal of datasource leads to left over illegal field configurations).

To fix this on your site, instead just export the index (admin/config/development/configuration/single/export), manually rename the search_api_node_grants field to just node_grants (or anything else – removing the whole field should also work) and re-import it (admin/config/development/configuration/single/import).

The attached patch should fix this for all future installations.

The last submitted patch, 3: 2761749-3--db_defaults_node_access_field_id--tests_only.patch, failed testing.

AsadKamil’s picture

Status: Needs review » Reviewed & tested by the community

Patch applied successfully,
thanks.

AsadKamil’s picture

Status: Reviewed & tested by the community » Needs review
frankcarey’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies and works after reinstalling the module.

  • drunken monkey committed 65f5023 on 8.x-1.x
    Issue #2761749 by drunken monkey: Fixed name of the "Node grants" field...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks for reporting back!
Committed.

Status: Fixed » Closed (fixed)

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

adhariwal’s picture

Version: 8.x-1.x-dev » 8.x-1.0-beta3
Issue summary: View changes

This issues still exists. Not all the instances of `search_api_node_grants` are updated.

adhariwal’s picture

rboedeker’s picture

Version: 8.x-1.0-beta3 » 8.x-1.0

#12 worked for me with social 8.x-1.0-rc5 (Drupal 8.3.2 / Search_Api 8.x-1.0 / php 7.0.15 / mysql 5.7.18) and some tweaks in social_search.

Are there any plan to include this patch into a next release?

nileshlohar’s picture

Version: 8.x-1.0 » 8.x-1.x-dev
FileSize
2.3 KB

Re-rolling patch in #12 for latest dev version.

drunken monkey’s picture

Status: Closed (fixed) » Needs review

Please, please, do not write into a closed issue! The maintainers will have almost no chance of seeing your posts unless they stumble over them by accident. If you can't re-open the issue, please just create a new one referencing it.

As for the issue itself: I'll look into it. However, with a brief glance I don't see how this can be a problem. That the property path starts with search_api is by design, to have it properly namespaced and avoid any potential clashes with other modules. But when creating a field from that property, \Drupal\search_api\Utility\FieldsHelper::getNewFieldId() should actually make sure to remove that prefix, and also not return a reserved field ID. If you have an erorr, it means the field must be added in some other way. Do you maybe have a backtrace for that or something?

The last submitted patch, 12: 2761749-12--db_defaults_node_access_field_id.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 14: search_api_node_grants-2761749-14.patch, failed testing. View results

drunken monkey’s picture

Priority: Critical » Normal
Status: Needs work » Postponed (maintainer needs more info)

Can't reproduce this.

ksavoie’s picture

Experiencing the same issue running D8.3.7, SOLR 6.4, Search_API 1.4.

Can't save fields:
search_api_node_grants is a reserved value and cannot be used as the machine name of a normal field.

Any ETA as to when this patch might make it to production?
Thanks

drunken monkey’s picture

Any ETA as to when this patch might make it to production?

Unless I can reproduce this or get a failing test case, nothing is going to happen. And even then, the proposed patch wouldn't be the correct solution for this.

Do you have more exact steps to reproduce? What exactly are you doing to cause that error message to appear?

joel_osc’s picture

FileSize
168.46 KB

I am running into this issue as well using Open Social - #2936146: Cannot save 'social_content' search api index fields. If you want to recreate the problem the easiest method might be to download Open Social and try to add a field (event type) to the Social Content index. Here is a screenshot of it for reference.

joel_osc’s picture

Status: Postponed (maintainer needs more info) » Needs review
drunken monkey’s picture

Status: Needs review » Closed (duplicate)

Ah, awesome! That explains it.
Then I’ll just close here as a duplicate. If others running into this issue and they’re not using Open Social: Was your index automatically created by some module/distribution? If so, that module/distribution is probably at fault, please post an issue there (or search for an existing one).
If the problem still exists for manually created indexes: please contact me via contact form and I’ll re-open.