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

MailEclipse drops Meilisearch/Laravel scout records #214

Open
vanrijs opened this issue Jul 8, 2022 · 6 comments
Open

MailEclipse drops Meilisearch/Laravel scout records #214

vanrijs opened this issue Jul 8, 2022 · 6 comments
Labels
bug Something isn't working Review Needed testing v5 version 5, supports both API and self hosted

Comments

@vanrijs
Copy link

vanrijs commented Jul 8, 2022

Describe the bug

Hi all,

Installed MailEclipse last week now I noticed that is drops my Meilisearch/Laravel scout index files.
Only loading MailEclipse drops the indexes to im 100% sure it has something to do with this.

Any ideas?

Reproduction steps

Steps to reproduce the behavior:

  1. Go to /maileclipse
  2. View your Meilisearch/Laravel Scout index files, they are empty

Laravel Version:

8.77

MailEclipse package version:

v3.5.3

@vanrijs vanrijs added bug Something isn't working Review Needed labels Jul 8, 2022
@ReeceM
Copy link
Collaborator

ReeceM commented Jul 8, 2022

Hi @vanrijs

Sorry to hear that the package is doing this, it clearly shouldn't be affecting other packages.

The only thing this sounds like is a possibility is that it is clearing db data for the mocking information.

If I could ask, could you do the following to establish where the bug is:

Use the maileclipse config and disable the usage of factories.

In all the mail ales, remove type hints to eloquent orm models. (It should be replaced with a dynamic object which will still show calls)

Generate your indexes

The visit the page again and please let me know what happens

@vanrijs
Copy link
Author

vanrijs commented Jul 8, 2022

Thanks @ReeceM. Im doing some tests now.
Disabled factory option but no results.
I model binded this:
public function __construct(Contract $contract) and this keeps dropping my records.
Removed this bind now and doing some additional tests. More in a few hours from now :)

@ReeceM
Copy link
Collaborator

ReeceM commented Jul 8, 2022

Thank you, please keep me updated on what happens

@vanrijs
Copy link
Author

vanrijs commented Jul 8, 2022

Hi @ReeceM. It has to do with the model bind.
My code now looks like this:

public function __construct($contract)
    {

        // model is already passed: its coming from an event listener
        if($contract instanceof Contract) {
            $this->contract = $contract;
        } else {
            $this->contract = Contract::with('responsible')->find(99475); // for editing mode, get fixed contract
        }

        $this->responsible = $this->contract->responsible;
    }

Don't have time now to do more research on what's going on exactly but my indexes keep intact now..

@ReeceM
Copy link
Collaborator

ReeceM commented Jul 8, 2022

Hi there @vanrijs,

So I would think that there would be a side effect from the package that when it creates a model using the factory. I am not sure if the scout package has a cascade side effect that drops data when the model is deleted as that is what the pacakge does after a factory is made...

What I'll have to do is to look though the other package to see what might be happening.

@ReeceM
Copy link
Collaborator

ReeceM commented Jul 8, 2022

So I may have to give this a bit of thought to get an idea of what to do.

Looking at the code there is a ModelObserver in the scout package that watches for deletes. Then clears out the index for that model. I suspect that if you are loading relations and other things like that it is possibly dropping those indexed details.

Do you think that it is possible to spin up a simple repository to create a reproduction of this issue?

@Qoraiche Qoraiche added v5 version 5, supports both API and self hosted testing labels Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Review Needed testing v5 version 5, supports both API and self hosted
Projects
None yet
Development

No branches or pull requests

3 participants