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

Cannot use object of type Algolia\\AlgoliaSearch\\Config\\SearchConfig as array #881

Closed
brocard opened this issue Nov 13, 2024 · 7 comments

Comments

@brocard
Copy link

brocard commented Nov 13, 2024

Scout Version

10.11.6

Scout Driver

Algolia

Laravel Version

11

PHP Version

8.2

Database Driver & Version

No response

SDK Version

No response

Meilisearch CLI Version

No response

Description

After insert in model with Searchable trait i receveid thir error

"message": "Cannot use object of type Algolia\\AlgoliaSearch\\Config\\SearchConfig as array", "exception": "Error", "file": "/Users/brocard/Projects/VALLARTA/AppKovayVacations/AppKovayApi/vendor/laravel/scout/src/Engines/Algolia3Engine.php", "line": 42,

Steps To Reproduce

Just after insert using the model with the trait or run the command php artisan scout:import Model Namespace

@brocard
Copy link
Author

brocard commented Nov 13, 2024

To fix this, we can use the methods provided by the SearchConfig object to access its properties, assuming they are accessible through methods or public properties. Here’s how you might approach it:

Inspect the SearchConfig object: Check which methods or properties are available. You can do this by running dd(get_class_methods($config)); to see the available methods or dd($config); to see its properties.

Replace array-style access with method calls: If, for example, getConnectTimeout() is a method of SearchConfig, you would replace $config['connect_timeout'] with $config->getConnectTimeout().

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@brocard
Copy link
Author

brocard commented Nov 13, 2024

This line its broken too, because $config->getAppId() its return an array and not an string

Screenshot 2024-11-13 at 0 23 58

Here is the problem the function create has $appid, and $apikey as parameter, and this moment is reciving and array
Screenshot 2024-11-13 at 0 35 22

@brocard
Copy link
Author

brocard commented Nov 13, 2024

This is the new code fixed it

Screenshot 2024-11-13 at 0 25 53

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@brocard
Copy link
Author

brocard commented Nov 13, 2024

The correct fix

Screenshot 2024-11-13 at 0 47 25

@crynobone
Copy link
Member

Fixed via #884

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

No branches or pull requests

2 participants