Fixes bug 848806 - Rewrite parameters before assigning default values in...

... search.

@peterbe r? 

No unit test here because that is some ugly code that should disappear asap (that being, I think, after we get rid of the PHP app, because the change will require changing the API).