Here is the standard diffbackend.php code for ImportFolderDeletion
- Code: Select all
function ImportFolderDeletion($id, $parent) {
//do nothing if it is a dummy folder
if ($parent == SYNC_FOLDER_TYPE_DUMMY)
return false;
$change = array();
$change["id"] = $id;
$this->updateState("delete", $change);
$this->_backend->DeleteFolder($parent, $id);
return true;
}
which is called from request.php by function HandleFolderCreate
- Code: Select all
if (!$delete) {
// Send change
$serverid = $importer->ImportFolderChange($serverid, $parentid, $displayname, $type);
}
else {
// delete folder
$deletedstat = $importer->ImportFolderDeletion($serverid, 0);
}
So - it is getting called with a folderID in $serverid - which passes to $id in DiffBackend, and a ZERO in the other parameter which passes to $parent in DiffBackend
The function ImportFolderDeletion is returning immediately - without doing anything.
To debug, I added debug some code.
- Code: Select all
function ImportFolderDeletion($id, $parent) {
debugLog( 'First test if parent == DUMMY? ' );
if ($parent == SYNC_FOLDER_TYPE_DUMMY) {
debugLog( 'ImportFolderDeletion!' );
debugLog( 'parent == DUMMY !' );
debugLog( 'Parent ['.$parent.']' );
debugLog( 'DUMMY ['.SYNC_FOLDER_TYPE_DUMMY.']' );
} else {
debugLog( 'parent != DUMMY !' );
}
debugLog( 'Now test if DUMMY == parent? (in case there is strange type casting happening)' );
if (SYNC_FOLDER_TYPE_DUMMY == $parent) {
debugLog( 'DUMMY == parent !' );
debugLog( 'Parent ['.$parent.']' );
debugLog( 'DUMMY ['.SYNC_FOLDER_TYPE_DUMMY.']' );
} else {
debugLog( 'DUMMY != parent !' );
}
//do nothing if it is a dummy folder
if ($parent == SYNC_FOLDER_TYPE_DUMMY)
return false;
....
And here is what I found.
For some bizarre reason the code is matching a $parentid of 0(ZERO) with SYNC_FOLDER_TYPE_DUMMY which is "__dummy.Folder.Id__" no matter which way round the comparison is done.
As a result of matching these - the function returns false without actually doing anything.
... [myUser] First test if parent == DUMMY?
... [myUser] ImportFolderDeletion!
... [myUser] parent == DUMMY !
... [myUser] Parent [0]
... [myUser] DUMMY [__dummy.Folder.Id__]
... [myUser] Now test if DUMMY == parent?
... [myUser] DUMMY == parent !
... [myUser] Parent [0]
... [myUser] DUMMY [__dummy.Folder.Id__]
Does anyone have a good explanation for why this is happening ?
Additionally, I think there is a further problem in the ImportFolderDeletion function - in that it should be operating on the basis of the return from the backend - not independently.
Rather than
- Code: Select all
$change = array();
$change["id"] = $id;
$this->updateState("delete", $change);
$this->_backend->DeleteFolder($parent, $id);
return true;
which tells the phone to do the deletion (updateState "delete") regardless of what the backend thinks - I believe it should be
- Code: Select all
$change = array();
$change["id"] = $id;
$deleted = $this->_backend->DeleteFolder($parent, $id);
if ($deleted) {
$this->updateState("delete", $change);
return true;
} else {
return false;
}
which looks to the backend to make the determination as to whether the phone is allowed to delete the folder or not.
