-
Notifications
You must be signed in to change notification settings - Fork 232
-
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!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Replies: 8 comments
-
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 :)
Beta Was this translation helpful? Give feedback.
All reactions
-
Same here
Beta Was this translation helpful? Give feedback.
All reactions
-
+1 on it.
I am getting the same on the whereIn.
Beta Was this translation helpful? Give feedback.
All reactions
-
Same for me
Beta Was this translation helpful? Give feedback.
All reactions
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
I'm experiencing the same problem, same place @axsweet, looks like someone fixed it on their on fork here: Nutickets@12feb91
Beta Was this translation helpful? Give feedback.
All reactions
-
@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. :)
Beta Was this translation helpful? Give feedback.
All reactions
-
I also encountered this error, with Eloquent Query like this:
$query->whereIn('id', function ($query) {
$query->select('category_id')
->from('categoriables')
->where('categoriable_type', Brand::class)
->whereIn('categoriable_id', function ($query) {
$query->select('id')
->from('brands')
->where('active', true);
});
});
Log
[2025年08月05日 01:39:19] local.ERROR: The arguments array must contain 2 items, 1 given {"exception":"[object] (ValueError(code: 0): The arguments array must contain 2 items, 1 given at vendor/mikebronner/laravel-model-caching/src/CacheKey.php:157)
[stacktrace]
#0 vendor/mikebronner/laravel-model-caching/src/CacheKey.php(157): vsprintf()
#1 vendor/mikebronner/laravel-model-caching/src/CacheKey.php(382): GeneaLabs\\LaravelModelCaching\\CacheKey->getInAndNotInClauses()
#2 vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(791): GeneaLabs\\LaravelModelCaching\\CacheKey->GeneaLabs\\LaravelModelCaching\\{closure}()
#3 vendor/mikebronner/laravel-model-caching/src/CacheKey.php(377): Illuminate\\Support\\Collection->reduce()
#4 vendor/mikebronner/laravel-model-caching/src/CacheKey.php(53): GeneaLabs\\LaravelModelCaching\\CacheKey->getWhereClauses()
#5 vendor/mikebronner/laravel-model-caching/src/Traits/Caching.php(182): GeneaLabs\\LaravelModelCaching\\CacheKey->make()
#6 vendor/mikebronner/laravel-model-caching/src/Traits/Buildable.php(106): GeneaLabs\\LaravelModelCaching\\CachedBuilder->makeCacheKey()
#7 app/Http/Presenters/DataPresenter.php(88): GeneaLabs\\LaravelModelCaching\\CachedBuilder->get()
#8 app/Repositories/CategoryRepository.php(33): App\\Http\\Presenters\\DataPresenter->renderCollection()
#9 app/Http/Controllers/V2/Category/CategoryController.php(32): App\\Repositories\\CategoryRepository->browse()
#10 vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\V2\\Category\\CategoryController->index()
#11 vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#12 vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#13 vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#14 vendor/laravel/framework/src/Illuminate/Routing/Router.php(806): Illuminate\\Routing\\Route->run()
#15 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#16 vendor/laravel/nightwatch/src/Hooks/RouteMiddleware.php(34): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#17 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Laravel\\Nightwatch\\Hooks\\RouteMiddleware->handle()
#18 vendor/spatie/laravel-responsecache/src/Middlewares/CacheResponse.php(46): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#19 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Spatie\\ResponseCache\\Middlewares\\CacheResponse->handle()
#20 vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#22 vendor/laravel/nightwatch/src/Hooks/GlobalMiddleware.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Laravel\\Nightwatch\\Hooks\\GlobalMiddleware->handle()
#24 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Pipeline\\Pipeline->then()
#26 vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\\Routing\\Router->runRouteWithinStack()
#27 vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\\Routing\\Router->runRoute()
#28 vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Router->dispatchToRoute()
#29 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#30 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#31 vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#33 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#35 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#36 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#37 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#38 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#39 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#41 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#43 vendor/laravel/nightwatch/src/Hooks/GlobalMiddleware.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Laravel\\Nightwatch\\Hooks\\GlobalMiddleware->handle()
#45 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#47 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#48 public/index.php(60): Illuminate\\Foundation\\Http\\Kernel->handle()
#49 /home/rdp77/.config/composer/vendor/cpriego/valet-linux/server.php(239): require('...')
#50 {main}
"}
Beta Was this translation helpful? Give feedback.