listfolders.php finds too many folders
-
I have a very weird effect here with one user.
listfolders.php -l USERNAME lists more than 800 folders for this user.
In the Webapp/Deskapp the user has only around 100 folders visible.The names of the folders all seem to be names that are used in this company. They might either be sub-folders of the public-folder structure, or they could have been deleted folders in this mailbox. This I cannot tell for sure, but they are not in the trash, I checked this.
Any idea what is happening here? Is there a way to purge/compress mailboxes to prevent this behavior, or is this a bug of the listfolders.php script?
I did not count all folders, but for the other mailboxes on this server, the returned folders all seem reasonable. It’s only on mailbox with this behavior.
Best regards
Patrick -
Hi Patrick,
listfolders only gets public folders if USERNAME is SYSTEM. Did you compare the listfolders output for -l SYSTEM and -l USERNAME?
Are most of the folders which aren’t in webapp of type SYNC_FOLDER_TYPE_USER_MAIL? Maybe not all folders in webapp are expanded and it appears that there are less folders?
Manfred
-
Hi Manfred,
sorry for the late reply.I was investigating the user folders (not the public folders for USER SYSTEM) on a kopano system and tried to find out how many subfolders each user approximately has.
All of the folders shown in the listfolders.php that I cannot find in the webapp are of type SYNC_FOLDER_TYPE_USER_MAIL.
I went through all folders in the webapp and checked that all levels are expanded.
listfolders.php reports 766 folders of type SYNC_FOLDER_TYPE_USER_MAIL, but there are only 104 expanded folders in webapp.I triple checked by now, and the user himself is also sure he does not have that many subfolders.
I have no idea where these folders come from. I can only guess that they are old folders previously deleted but somehow still referenced in the mailbox or a bug in kopano.
As stated before it is only one user mailbox. All other mailboxes on this server return reasonable results when checking with listfolders.
Any ideas on how to purge/repair the user mailbox?
Regards,
Patrick
-
Hi Patrick,
in order to debug it further, please make the following changes to listfolders.php.
Alter line 180 so that it looks like this:
$subfolders = @mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_CONTAINER_CLASS, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_FOLDER_TYPE, PR_ATTR_HIDDEN, PR_PARENT_ENTRYID));
(added PR_PARENT_ENTRYID to the property list).
At line 204 add the following lines (after the line
echo "Type:\t\t". $supported_classes[$folder[PR_CONTAINER_CLASS]] . "\n";
):if ($folder[PR_PARENT_ENTRYID] == $storeProps[PR_IPM_WASTEBASKET_ENTRYID]) { echo "Folder is in the deleted items\n"; } else { echo "Parent ID:\t\t". bin2hex($folder[PR_PARENT_SOURCE_KEY]) . "\n"; }
It will print if a folder was indeed deleted and is in the deleted items folder. In such a case emptying the deleted items folder will remove them (just right click the deleted items folder in webapp and select Empty Deleted items).
Otherwise it will print the id of the parent folder and then searching for it in the output of the listfolders you’ll hopefully find the folder or folders in which they are. Maybe this will also shed some light on what’s going on.Had the user his store restored from backup at some point? Or another store hooked to his store?
Manfred
-
Hi Manfred,
somehow I never get emails when you answer in my thread though I am watching this thread. So I keep forgetting to look here. Sorry for the late reply.Thanks for the script enhancements. I implemented these and did some research with the results (using some bash sorting/ greping/…)
The result ist: out of reported 767 folders in this user mailbox, there are:
2 deleted folders (wich are visible in the webapp in the deleted items folder) -> correct.
188 folders which have a parent id which is not existent (or at least not in this mailbox)
out of these 188 folders there are 52 unique folder ids that are missing
The rest of the invisible folders seem to be linked to these 188 folders as a tree.So the interesting question is: What happend to these 52 missing / invisible Parent folders?
I do not remember restoring this mailbox from backup or hooking a different store since the setup of the kopano server in 2017. I cannot say for sure how the migration from the old zarafa server to the kopano server was done back in 2017.
This might have been done by using a backup, but I’m not sure about this anymore.Any ideas on how to continue solving this mystery?
Regards Patrick
-
Hi Patrick,
did the user used Outlook at some point? Or still uses? It’s also possible that those folders come from there.
Or maybe they reference folders of some other user. Did you compare those missing ids with those from SYSTEM or other users?
Other than that you probably could do some research on the database directly, but I strongly suggest to contact support and have assistance before doing that.
Manfred
-
Hi Manfred,
Outlook has not been used with the kopano server. It has been used on the old zarafa server, from where the mailboxes were migrated about two years ago.
I cannot find any matching folder ID in the System or any other user for those 52 missing parent folders.
Just to clarify: The user is not missing any folders.
I guess I should contact support to investigate this further, or do you know a way to rebuild a mailbox index or to purge/cleanup the mailbox?
Regards
Patrick