[horde] Pretty sure I found Bug in Trean (Bookmarks)

Michael M Slusarz slusarz at horde.org
Mon Oct 7 18:58:30 UTC 2013


Quoting Andy Dorman <adorman at ironicdesign.com>:

> On 10/03/2013 08:32 AM, Andy Dorman wrote:
>> I have tested this fix as well and it works fine...
>>
>>>    public function listBookmarks($sortby = 'title', $sortdir = 0,
>>> $from = 0, $count = 0)
>>>    {
>>>        $values = array($this->_userId);
>>>        $sql = 'SELECT bookmark_id, user_id, bookmark_url,
>>> bookmark_title, bookmark_description, bookmark_clicks,
>>> bookmark_http_status, favicon_url, bookmark_dt
>>>                FROM trean_bookmarks
>>>                WHERE user_id = ?
>>>                ORDER BY bookmark_' . ($sortby ? $sortby : 'title') .
>>> ($sortdir ? ' DESC' : '');
>>>        $sql = $GLOBALS['trean_db']->addLimitOffset($sql,
>>> array('limit' => $count, 'offset' => $from));
>>
>> It still seems silly to me that PHP apparently considers the empty
>> string or whatever is being passed for $sortby to be a valid value and
>> does not invoke the default for it.

Not silly at all.  This is basic PHP comparison logic - an empty  
string is considered a false value for purposes of a boolean  
comparison.  See:

http://php.net/manual/en/function.empty.php

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the horde mailing list