[dev] [commits] Horde branch master updated. f7b75dbcebed550d35027b95d70b65bafb5723bf

Thomas Jarosch thomas.jarosch at intra2net.com
Thu Oct 17 09:14:22 UTC 2013


Hi MJR,

On Wednesday, 16. October 2013 14:33:53 you wrote:
> commit f7b75dbcebed550d35027b95d70b65bafb5723bf
> Author: Michael J Rubinsky <mrubinsk at horde.org>
> Date:   Wed Oct 16 10:30:32 2013 -0400
> 
>     Load all matching map entries for available changes at once.
> 
>     Don't hit the DB for each change, we already have all the change uids,
> so fetch all the possible map entries at once.
> 
>  framework/ActiveSync/lib/Horde/ActiveSync/State/Sql.php |   56
> ++++++++------- 1 files changed, 31 insertions(+), 25 deletions(-)
> 
> http://github.com/horde/horde/commit/f7b75dbcebed550d35027b95d70b65bafb572
> 3bf
> http://git.horde.org/horde-git/-/commit/f7b75dbcebed550d35027b95d70b65baf
> b5723bf

hmm, I think you need to tweak the SQL statement for this some more.
The new code:

+
+        $conditions = '';
+        foreach ($changes as $change) {
+            $d = $change['type'] == Horde_ActiveSync::CHANGE_TYPE_DELETE;
+            if (strlen($conditions)) {
+                $conditions .= 'OR ';
+            }
+            $conditions .= '(message_uid = ?' . ($d ? ' AND sync_deleted = ?) ' : ') ');
+            $values[] = $change['id'];
+            if ($d) {
+                $values[] = $d;
+            }
+        }
+        $sql .= 'AND ' . $conditions . 'GROUP BY message_uid';
         try {
-            return $this->_db->selectValue($sql, $values);
+            return $this->_db->selectAssoc($sql, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Horde_ActiveSync_Exception($e);
         }


-> We need parenthesis around the "AND ($conditions)",
otherwise we "OR" multiple conditions with the whole SQL statement
which is not what we want.

If you tweak the code anyway: No need to use strlen()
to check if a string is empty ;)

Cheers,
Thomas



More information about the dev mailing list