Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comments
Comment #2
claudiu.cristeaI confirm this bug with latest from HEAD (895b50787d54cd3f6bc3f8d4833cec809a8d021d). And this is critical because it prevents saving the fields form.
Comment #3
drunken monkeyThanks 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 thesearch_api_node_grants
field to justnode_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.
Comment #5
AsadKamil CreditAttribution: AsadKamil at Valuebound commentedPatch applied successfully,
thanks.
Comment #6
AsadKamil CreditAttribution: AsadKamil at Valuebound commentedComment #7
frankcarey CreditAttribution: frankcarey as a volunteer and at DEVINCI commentedPatch applies and works after reinstalling the module.
Comment #9
drunken monkeyGood to hear, thanks for reporting back!
Committed.
Comment #11
adhariwal CreditAttribution: adhariwal at Axelerant commentedThis issues still exists. Not all the instances of `search_api_node_grants` are updated.
Comment #12
adhariwal CreditAttribution: adhariwal at Axelerant commentedComment #13
rboedeker CreditAttribution: rboedeker commented#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?
Comment #14
nileshlohar CreditAttribution: nileshlohar commentedRe-rolling patch in #12 for latest dev version.
Comment #15
drunken monkeyPlease, 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?Comment #18
drunken monkeyCan't reproduce this.
Comment #19
ksavoie CreditAttribution: ksavoie commentedExperiencing 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
Comment #20
drunken monkeyUnless 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?
Comment #21
joel_osc CreditAttribution: joel_osc at OpenPlus commentedI 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.
Comment #22
joel_osc CreditAttribution: joel_osc at OpenPlus commentedComment #23
drunken monkeyAh, 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.