External issue Search error for subset of users: withPermissionConstraints(): Argument #2 ($constraints) must be of type array, false given

constants

New member
Licensed customer
Affected version
2.3.12
Hello,

We are running into a problem where a random-seeming subset of our users always get errors when using search. I'm personally not able to reproduce the error.
We do NOT have Enhanced Search enabled.

I've searched for this bug here, but I was unable to find a match.

Error logs:

TypeError: XF\Search\Query\Query::withPermissionConstraints(): Argument #2 ($constraints) must be of type array, false given, called in /home/username/public_html/src/XF/Search/Search.php on line 403
src/XF/Search/Query/Query.php:377


Stack trace:

#0 src/XF/Search/Search.php(403): XF\Search\Query\Query->withPermissionConstraints(Array, false)
#1 src/XF/Search/Search.php(373): XF\Search\Search->applyPermissionConstraints(Object(XF\Search\Query\KeywordQuery))
#2 src/XF/Search/Search.php(341): XF\Search\Search->executeSearch(Object(XF\Search\Query\KeywordQuery), 200, Object(Closure), true)
#3 src/XF/Repository/SearchRepository.php(26): XF\Search\Search->search(Object(XF\Search\Query\KeywordQuery))
#4 src/XF/Pub/Controller/SearchController.php(480): XF\Repository\SearchRepository->runSearch(Object(XF\Search\Query\KeywordQuery), Array, true)
#5 src/XF/Pub/Controller/SearchController.php(101): XF\Pub\Controller\SearchController->runSearch(Object(XF\Search\Query\KeywordQuery), Array)
#6 src/XF/Mvc/Dispatcher.php(364): XF\Pub\Controller\SearchController->actionSearch(Object(XF\Mvc\ParameterBag))
#7 src/XF/Mvc/Dispatcher.php(266): XF\Mvc\Dispatcher->dispatchClass('XF:Search', 'Search', Object(XF\Mvc\RouteMatch), Object(vw\vw\XF\Pub\Controller\Search), NULL)
#8 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(vw\vw\XF\Pub\Controller\Search), NULL)
#9 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src/XF/App.php(2830): XF\Mvc\Dispatcher->run()
#11 src/XF.php(850): XF\App->run()
#12 index.php(23): XF::runApp('XF\\Pub\\App')
#13 {main}


Request state:

array(4) {
["url"] => string(14) "/search/search"
["referrer"] => string(57) "https://www.domainname.com/forums/threadname.22/page-2"
["_GET"] => array(0) {
}
["_POST"] => array(4) {
["keywords"] => string(7) "raccoon"
["constraints"] => string(0) ""
["c"] => array(1) {
["users"] => string(0) ""
}
["_xfToken"] => string(8) "********"
}
}


I'm unsure if this is relevant, but outside of the Xenforo Gallery and Xenforo Resource add-ons, we do have a number of other add-ons enabled, namely VaultWiki, Classifieds, App for Cloudflare, and a theme.

Please let me know if there's any other information that's needed to help resolve this problem.

Thank you!
 
Hi,
I think the error is occurring because getTypePermissionConstraints() (or the equivalent permission-constraint method on a search data handler) is returning false for one of your enabled content types, instead of returning either an array of constraints or true/false in the way XF\Search\Search::applyPermissionConstraints() expects to handle exclusion. When that happens, the false value gets passed straight through into Query::withPermissionConstraints(), which strictly type-hints its second argument as array, hence the TypeError.

In other words: this isn't a search-query problem (the keyword "raccoon" and the empty constraints/c[users] POST fields are normal, unremarkable search form values), it's a permission-constraint value from one of the searchable content types being malformed for a specific combination of user permission.

To determine the source, can you provide the following to me:
  1. XenForo version, and the current versions of VaultWiki and Classifieds specifically.
  2. Whether the error reproduces for guests (logged out), or only logged-in users.
  3. If possible, ask one of the affected users what usergroup(s) they belong to (primary + secondary), and whether that differs meaningfully from an unaffected user/admin account.
  4. As a diagnostic step (not necessarily a permanent fix): temporarily disable VaultWiki and Classifieds and have an affected user retry the same search. If the error stops, that confirms which add-on's search handler is at fault, and we can narrow the fix to that specific permission edge case.
  5. If you're comfortable doing so, a quick check of each add-on's search data handler class (look for a method along the lines of getTypePermissionConstraints()) for any conditional branch that could return false instead of true or an array — happy to take a look directly if you can share the relevant file.
So I can propose the best possible solution for your problem.

Thank You!
 
Hi,
I think the error is occurring because getTypePermissionConstraints() (or the equivalent permission-constraint method on a search data handler) is returning false for one of your enabled content types, instead of returning either an array of constraints or true/false in the way XF\Search\Search::applyPermissionConstraints() expects to handle exclusion. When that happens, the false value gets passed straight through into Query::withPermissionConstraints(), which strictly type-hints its second argument as array, hence the TypeError.

In other words: this isn't a search-query problem (the keyword "raccoon" and the empty constraints/c[users] POST fields are normal, unremarkable search form values), it's a permission-constraint value from one of the searchable content types being malformed for a specific combination of user permission.

To determine the source, can you provide the following to me:
  1. XenForo version, and the current versions of VaultWiki and Classifieds specifically.
  2. Whether the error reproduces for guests (logged out), or only logged-in users.
  3. If possible, ask one of the affected users what usergroup(s) they belong to (primary + secondary), and whether that differs meaningfully from an unaffected user/admin account.
  4. As a diagnostic step (not necessarily a permanent fix): temporarily disable VaultWiki and Classifieds and have an affected user retry the same search. If the error stops, that confirms which add-on's search handler is at fault, and we can narrow the fix to that specific permission edge case.
  5. If you're comfortable doing so, a quick check of each add-on's search data handler class (look for a method along the lines of getTypePermissionConstraints()) for any conditional branch that could return false instead of true or an array — happy to take a look directly if you can share the relevant file.
So I can propose the best possible solution for your problem.

Thank You!
Thank you for the advice!

We were able to determine that users without access to the Classifieds plugin ran into the problem, while those with access to the Classifieds plugin did not. We have provided this information to the Classifieds plugin developers to see if anything can be done to fix it.
 
Automated triage: Third party

The error comes from a search handler supplied by one of your add-ons. It returns an invalid value for some users' permissions, and every built-in XenForo search type handles this correctly. Please disable VaultWiki and Classifieds one at a time to confirm which one it is, then report it to that add-on's developer.

This is an automated assessment. A member of staff may review and update it.
 
Back
Top Bottom