• I’m receiving an “Invalid argument supplied for foreach()” error if I run a search on a non-existent search token (was trying to make sure I wasn’t repeating myself about a particular topic so ran a search to make sure). Couldn’t find this addressed in any previous support threads.
    How are you handling a return from the mySql query of no rows, in such cases as this or calls to b2.php?p=nonexistent_post_id ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi
    I cannot reproduce this.
    When I searched for ‘zzz’ on a brand new WP installation (version 0.7.1.1) I just got an empty template.
    No error message.
    Mike

    Yes we fixed that, but it’s a change to the template. If you didn’t update your templates you wouldn’t get the fix. Basically it’s just wrapping the foreach in a if statement that checks if there are actually any results.

    Thread Starter geistvox

    (@geistvox)

    I was starting to not believe you, having looked at the b2.php file in my copy of the 0.71 Gold release. I did find the aforementioned if-statement in the index.php. Might want to update the b2.php file, if you have not done so already or drop the file altogther.

    I deleted the first default post and got the same error. Since there is nothing in the database, the select probably returns an empty list, which php interperets as false, and so the foreach fails. That’s just my guess, and it is a little different from the search thing.

    I think these have all be caught in the CVS.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search function breaks on non-existent token’ is closed to new replies.