suntrop Posted 2 hours ago Share Posted 2 hours ago I noticed something strange, with a selector I cannot explain why this happens. $item_number = ' '; $p = wire('pages')->get('template=product, item_number=' . $item_number); echo $p->title; The code above finds a page with an item_number set to the value of "50032". There is no space (had a look at the DB). I would have though using the = operator the code above gets nothing or if present something with an empty item_number. But no with a totally different value. It works as expected if I change the code to: $p = wire('pages')->get("template=product, item_number='{$item_number}'"); Does anybody know why the first code example works differently? PW 3.0.243 Link to comment Share on other sites More sharing options...
elabx Posted 2 hours ago Share Posted 2 hours ago Might there be something in the trash with that number? get() skips any access control check! Link to comment Share on other sites More sharing options...
suntrop Posted 2 hours ago Author Share Posted 2 hours ago No, it's deftly that particular page, just sitting in the page tree like many others. It is, by the way, the first page in the page tree with an item_number (the pages above have empty item_number values). Link to comment Share on other sites More sharing options...
da² Posted 28 minutes ago Share Posted 28 minutes ago Both codes are NOT giving the same selector, you could check by printing it. First case gives: "item_number= " (with a space) Second one gives: "item_number=' '" (space inside quotes) To find empty values, you can just use "item_number=''" (no space inside quotes), or "item_number=" (nothing after equal). But I don't know why the first one is returning a page with item_number=50032. If you're sure everything is right on your side, maybe report a bug on Github. Link to comment Share on other sites More sharing options...
suntrop Posted 9 minutes ago Author Share Posted 9 minutes ago Thanks for your answer. To clarify, I don't want to get pages with empty values, nor do I have a problem with finding what I need. I'm curious why a blank search query produces non-blank results. I might post this question on GitHub later. 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