Page MenuHomekolab.org

Top level folder names as numbers
Closed, ResolvedPublic

Description

When a top-level folder is created in Outlook, which name is only a number, Syncroton fails to sync this folder. Error in the log (displayname=2016):

[06-Apr-2016 09:34:14 +0200]: DB Error: [1048] Column 'folderid' cannot be null (SQL Query: INSERT INTO syncroton_folder (folderid, parentid, displayname, type, creation_time, device_id, class, id) VALUES(NULL, '0', '2016', '12', '2016-04-06 07:34:13', '80170bf417c1d98a26b78e0ab63110538088a29f', 'Email', 'e21eb9b8881b6546f418d26e3419e68350932b00')) in /usr/share/roundcubemail/program/lib/Roundcube/rcube_db.php on line 539 (POST /Microsoft-Server-Active
Sync?Cmd=FolderSync&User=szszep&DeviceId=32D57F3C354A4D5089FC2C4EF456D8CB&DeviceType=WindowsOutlook15)

When the folder is named something else (like "year2016"), it is OK.

This patch solves the problem for me (maybe it would be better to catch the number earlier?):

--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -726,9 +726,10 @@ class kolab_sync_backend
         // ActiveSync expects folder identifiers to be max.64 characters
         // So we can't use just folder name
 
-        if ($name === '' || !is_string($name)) {
+        if ($name === '') {
             return null;
         }
+        $name=(string)$name;
 
         if (isset($this->folder_uids[$name])) {
             return $this->folder_uids[$name];

Details

Ticket Type
Task

Event Timeline

gyurco created this task.Jun 1 2016, 4:39 PM
vanmeeuwen assigned this task to machniak.
vanmeeuwen added a subscriber: vanmeeuwen.

Albeit the suggested fix seems flawed not unlike the original code (returning null should probably happen only after an int is converted to a string, then compared to ''), I also have to note that apparently $name here is passed on as an integer and not it's string representation(???).

Surely, a folder named '1' should be passed along the software stack as a (string)1. Perhaps this is a Mikkiesoft client problem exposed to our software through WBXML parsing?

vanmeeuwen moved this task from Backlog to Reviewed on the Bug Reports board.Jun 1 2016, 6:11 PM
machniak added a comment.EditedJun 5 2016, 6:48 PM

Looks like a feature/bug of PHP where numeric array keys (here folder names) in foreach are converted to int. I'm talking about the loop in kolab_sync_backend::folders_list(). I'm working on a fix.

machniak closed this task as Resolved.Jun 5 2016, 7:00 PM
machniak moved this task from Backlog to Done on the Syncroton board.Oct 17 2016, 9:10 AM