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

[4.1.0-beta.1] Queue Error When Saving an Entry When Using getElements #297

Closed
simonkuran opened this issue May 1, 2024 · 8 comments
Closed
Assignees

Comments

@simonkuran
Copy link

simonkuran commented May 1, 2024

Thanks @janhenckens for the work on #69! I have a test setup and I'm getting an error when saving an entry. When updating the index via php craft scout/index it works. However, when I then save an entry I get an "Indexing element Failed" error in the CP queue. In the queue log file I get a {main} {"memory":7540904,"exception":"[object] (Error(code: 0): Call to a member function id() on array at /var/www/html/vendor/studioespresso/craft-scout/src/jobs/MakeSearchable.php:81)"} error.

Here's the core of my scout.php file:

use \craft\base\Element;
use \craft\elements\Entry;
use \Solspace\Calendar\Elements\Event;

return [
    'indices' => [
        \rias\scout\ScoutIndex::create('global')
        ->getElements(function () {
            return [
                Entry::find()->section('blog'),
                Event::find()
            ];
        })
        ->transformer(function (Element $element) {
            $moduleBody = $element->modules->type('body')->all();
            $moduleBodyContent = [];
            foreach($moduleBody as $block) {
                $moduleBodyContent[] = $block->body;
            }

            return [
                'title' => $element->title,
                'postDate' => $element->postDate,
                'moduleBody' => $moduleBodyContent,
            ];
        })
        ->indexSettings(
            \rias\scout\IndexSettings::create()
                ->minWordSizefor1Typo(4)
        )
    ],
];

When I use a a single element type like this I don't get any errors:

->elementType(Entry::class)
->criteria(function (\craft\elements\db\EntryQuery $query) {
    return $query->section('blog');
})
@janhenckens janhenckens changed the title Queue Error When Saving an Entry that [4.1.0-beta.1] Queue Error When Saving an Entry that May 1, 2024
@janhenckens janhenckens self-assigned this May 1, 2024
@janhenckens
Copy link
Member

Thanks for testing @simonkuran! I can reproduce so I'll look into it, hope to be able to give you and update by the end of the week.

@simonkuran simonkuran changed the title [4.1.0-beta.1] Queue Error When Saving an Entry that [4.1.0-beta.1] Queue Error When Saving an Entry when using ->getElements May 1, 2024
@simonkuran simonkuran changed the title [4.1.0-beta.1] Queue Error When Saving an Entry when using ->getElements [4.1.0-beta.1] Queue Error When Saving an Entry When Using ->getElements May 1, 2024
@simonkuran simonkuran changed the title [4.1.0-beta.1] Queue Error When Saving an Entry When Using ->getElements [4.1.0-beta.1] Queue Error When Saving an Entry When Using getElements May 1, 2024
@elivz
Copy link

elivz commented May 3, 2024

I am seeing the same issue. Appears to have started with Scout v3.3.3.

janhenckens added a commit that referenced this issue May 4, 2024
@janhenckens
Copy link
Member

I am seeing the same issue. Appears to have started with Scout v3.3.3.

This specific issue was through a change that was introduced last week and is only present in 4.1.0-beta.1 for now. Are you running that version as well @elivz?

@janhenckens
Copy link
Member

@simonkuran Could to try updating to 4.1.0-beta.2 and see if that fixes this for you? Thanks!

@elivz
Copy link

elivz commented May 4, 2024

Interesting, no I was on 3.3.3 but getting the exact same error in the logs (including the same line number). I downgraded to 3.3.2 which cleared up my error logs. I can try to do a little more testing on Monday with newer versions.

@simonkuran
Copy link
Author

@janhenckens 4.1.0-beta.2 is working well for me. Thanks for fixing this so quickly.

@janhenckens
Copy link
Member

@janhenckens 4.1.0-beta.2 is working well for me. Thanks for fixing this so quickly.

Thanks for testing!

@janhenckens
Copy link
Member

Interesting, no I was on 3.3.3 but getting the exact same error in the logs (including the same line number). I downgraded to 3.3.2 which cleared up my error logs. I can try to do a little more testing on Monday with newer versions.

Could you try to update to the latest stable version (4.0.0) and report a new issue with your scout config if you're still having the problem? Thanks!

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

3 participants