IMAP backend search not working (filter becomes before 1970-01-01 and after 1970-01-01)

I found email search not working from Android today. Tracked it down to the search filter giving after and before dates of 1970.

In the code in BackendIMAP::getSearchRestrictions:
$searchGreater = strftime("%Y-%m-%d", strtotime($cpo->GetSearchValueGreater()));
$searchLess = strftime("%Y-%m-%d", strtotime($cpo->GetSearchValueLess()));

$cpo search values are empty, and strtotime is returning false, which strftime is happily converting to a time string like 1970-01-01 for both.

I replaced with
$searchGreater = ‘’;
$searchLess = ‘’;
if ($t = strtotime($cpo->GetSearchValueGreater())) {
$searchGreater = strftime("%Y-%m-%d", $t);
if ($t = strtotime($cpo->GetSearchValueLess())) {
$searchLess = strftime("%Y-%m-%d", $t);

and search is working fine for me now.

Seems like a new problem as I’ve seen posts from others with debug showing proper dates in the filter string?

Hi freescape,

would you like to contribute the fix to the Z-Push community? See for more information.


Hrrm, I know about as much about PHP as I do about playing the Antagonistic Undecagonstring two-handed… so sure, why not! :-)