Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

If adding this module with no configuration, the Search Service admin is broken #83

Open
GuySartorelli opened this issue May 9, 2023 · 1 comment

Comments

@GuySartorelli
Copy link
Member

After adding this module to a fresh installation of Silverstripe CMS 4.13, and not adding any specific configuration, accessing /admin/search-service/ gives the following error:

Uncaught LogicException: GridField doesn't have a modelClassName, so it doesn't know the columns of this grid.

This is because buildIndexedDocumentsList() doesn't add anything to the list if there are no indexed, which means the ArrayList doesn't ever set its data class.

Possible Solutions

Option 1

This is the most straight forward: Call $list->setDataClass(IndexedDocumentsResult::class); on the empty ArrayList as soon as it's created. That way, whether there are any indexes configured or not, the user won't get an unhelpful error.

Option 2

If the list is empty, throw a meaningful exception indicating that no indexes have been configured. This is a little less straight forward because you have to decide on the exact wording, but it does make it a lot clearer that the developer needs to perform some action.

Option 3

I don't recommend this solution, but it is one of the options available so I'll mention it anyway.
If there are no indexes configured, hide the Search Service admin altogether.

@michalkleiner
Copy link

Option 1 with a conditional notice above the GF with a link to docs on how to configure the index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants