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

Undefined index: name in Autocomplete/Category/ItemFactory.php #1855

Closed
PivitParkour94 opened this issue Jun 18, 2020 · 4 comments
Closed

Undefined index: name in Autocomplete/Category/ItemFactory.php #1855

PivitParkour94 opened this issue Jun 18, 2020 · 4 comments
Assignees
Labels

Comments

@PivitParkour94
Copy link

Preconditions

PHP 7.3

Magento Version : 2.3.5-p1 (Open Source)

ElasticSuite Version : N/A

Environment : Production

Third party modules :

Steps to reproduce

Found that the following error is being thrown
[DATE] main.CRITICAL: Notice: Undefined index: name in /vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/Autocomplete/Category/ItemFactory.php on line 100

Expected result

Should check for the name key in the array before using it.

Actual result

Sometimes the name is missing and throws an error.

The error being thrown doesn't seem to effect the functionality, just can become an issue when extra logs are being thrown that aren't needed.

@androshchuk androshchuk self-assigned this Jun 19, 2020
@androshchuk
Copy link
Contributor

Hello @PivitParkour94
I can't reproduce it in my environment.
Could you provide more information when this happens?
Perhaps the problem is deeper.

Regards

@PivitParkour94
Copy link
Author

That's the issue. Not too sure what's causing it, but somehow the document source is being loaded with the name field missing. We've just noticed the log creeping up with these errors, it most likely is bad data in the database, but verifying an array key is set before using it is a good way to avoid these issues.

We have patched it locally and it would be good to not have to maintain our own patched version, if we're getting this error once, someone somewhere else will also get this error. Just wanting to help make the module more stable.

Would you prefer I make a PR and you can accept/reject it as you see fit? I'd rather not put in the effort if it will just be rejected.

Cheers

@androshchuk
Copy link
Contributor

Hello @PivitParkour94
You can do PR and we'll consider it in the near future.

Regards

@romainruaud
Copy link
Collaborator

Yes, we should check the array key before using it, for sure. Most probably, we should not return anything from the ItemFactory if name is missing : we would not have anything to display into the autocomplete box.

Most probably, the origin of the bug can be :

  • the name attribute for categories is not set to is_searchable=1 meaning there is nothing in the index. We should ensure that in our Setup files and/or indices XML we enforce category name to be searchable.
  • the category really has an empty name : in this case, we get back to step 1 and should not in any case try to display it into the autocomplete box.

@PivitParkour94 you can submit a PR if you want.

regards

romainruaud added a commit that referenced this issue Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants