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

whereIn Subquery Error - "vsprintf(): Too few arguments" #387

Open
joeyrush opened this issue Dec 10, 2020 · 7 comments
Open

whereIn Subquery Error - "vsprintf(): Too few arguments" #387

joeyrush opened this issue Dec 10, 2020 · 7 comments
Assignees

Comments

@joeyrush
Copy link

joeyrush commented Dec 10, 2020

Describe the bug
I'm experiencing a consistent error when using a subquery inside of a whereIn: vsprintf(): Too few arguments in CacheKey.php:255

Have tried stripping down to the absolute minimum reproducible and it seems to happen on the second where clause inside a whereIn subquery.

Eloquent Query

    TaxBand::query()
            ->whereIn('id', function ($query) {
                $query->select('abilities.entity_id')
                    ->from('abilities')
                    ->where('abilities.id', 1) // works fine up until here
                    ->where('abilities.name', 'manage'); // fails here
            })
            ->get();

Stack Trace
See: https://flareapp.io/share/VP636Qq7#F77

Environment

  • PHP: 7.4
  • OS: MacOS
  • Laravel: 8.13.0
  • Model Caching: 0.11.0 and 0.11.1

Additional context
Happy to provide anymore info, thank you!

@mikebronner
Copy link
Owner

Hi @joeyrush, thanks for submitting this issue! I will try to investigate this as soon as I can. I can't promise when this will be at this time, as we are in the middle of moving, but if it is something simple, I should be able to get it done within a week or two. You are more than welcome to also submit a PR with a failing test, and after that a PR that fixes the issue, if you have time.

Thanks again :)

@danielbehrendt
Copy link

Same here

@atasciuc
Copy link

atasciuc commented Jun 18, 2021

+1 on it.
I am getting the same on the whereIn.

@Art4es
Copy link

Art4es commented Jul 30, 2021

Same for me

joeyrush pushed a commit to Nutickets/laravel-model-caching that referenced this issue Oct 15, 2021
Correctly build cache key for whereIn subqueries
@axsweet
Copy link

axsweet commented Apr 26, 2022

I see part of the issue here, I grabbed latest code / repo also but part of the issue is when the keys or some checking for keys use symbols...specifically the "%" which I think throws it off... Check my stack trace: I think that is the issue, I am not going to dive into it, but just off hand that data is a serial number I guess listed in my db so when im using the model caching it started to mess it up, So dove in that what I see....
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'vsprintf(): Too...', '/u/sites/xfacts...', 157, Array)
#1 /696969/genealabs/laravel-model-caching/src/CacheKey.php(157): vsprintf('%WK1KD002555_%W...', Array)

%WK1SD001755 is the value

a few like that in the string is my guess. weird wasnt previously an issue till the last one was added.

tracked it back to /src/CacheKey.php(368): GeneaLabs\LaravelModelCaching\CacheKey->getInAndNotInClauses(

Obviously worked around it with catching a throwable and not using cache for this one fail of the like 30k that dont fail

@antonioribeiro
Copy link

I'm experiencing the same problem, same place @axsweet, looks like someone fixed it on their on fork here: Nutickets@12feb91

@mikebronner
Copy link
Owner

@antonioribeiro would you be open to submitting a PR for this change, based on the commit you referenced from Nutickets? That would really help a lot. :)

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

7 participants