Zeka Posted October 21, 2018 Share Posted October 21, 2018 Hi. I can't figurate out is it a bug or I miss something $selector = '(template=catalog_category|product), (id=1430|1530|1443|1528|1442|1441|1440|1527|1529|1439|1438|1437|1436|1531|1523|1522|1435|1433|1434)'; $some_pages = $pages->find($selector); $some_pages->has('id=1417') // true Then on the page with ID 1417 $page->matches($selector) // false As you can see that the page with ID 1417 is found by the selector, but do not match it. Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 22, 2018 Share Posted October 22, 2018 OR-Groups are not supported by the in-memory matcher. 1 Link to comment Share on other sites More sharing options...
Zeka Posted October 22, 2018 Author Share Posted October 22, 2018 @LostKobrakai It's not the first time when I met that something works with memory and not DB. Maybe the dumb question, but is there some way to determine it? (I guess the answer will be like - read source code ? ). 1 Link to comment Share on other sites More sharing options...
BitPoet Posted October 22, 2018 Share Posted October 22, 2018 54 minutes ago, Zeka said: It's not the first time when I met that something works with memory and not DB. Maybe the dumb question, but is there some way to determine it? It's in the selectors docs (admittedly, in the fine print at the bottom of the relevant section): Quote Please note: OR-groups work with database-driven find operations, but not with in-memory filtering (where they are less useful). OR-groups also require ProcessWire 2.5 or newer. 2 Link to comment Share on other sites More sharing options...
Tom. Posted October 22, 2018 Share Posted October 22, 2018 @Zeka There is many inconsistencies between in-memory and DB. Things being case sensitive etc. I'm recently seeing the inconsistency throw people more and more. As the API is the same - I think it's hard to know what's going to be DB and what's going to be in-memory. I think there are things that can be done to bring in-memory searches to bring it inline with DB searches. For now this should work: <?php $validation = []; preg_match_all('/\(([^\)]+)\)/' $selector, $matches); foreach($matches[1] as $match) { $validation[] = $page->matches($match); } if(in_array(true, $validation)) { // Page Matches one OR Group. } ?> I haven't tested it, but it should work, might require a little tweaking. Or <?php $validation = false; preg_match_all('/\(([^\)]+)\)/' $selector, $matches); foreach($matches[1] as $match) { if(!$validation) { $validation = $page->matches($match); } } if($validation) { // Page Matches one OR Group. } ?> 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now