dokuwiki-plugin-sync icon indicating copy to clipboard operation
dokuwiki-plugin-sync copied to clipboard

Sync not possible when remote side is read-only

Open cziehr opened this issue 5 years ago • 1 comments

If the user who is syncing has only read permissions on the remote wiki, the sync fails, because pages can't be locked.

I helped myself by commenting out the lines

foreach((array) $data['lockfail'] as $id){
$this->_listOut($this->getLang('lockfail').' '.hsc($id),'error');
unset($synclist[$id]);
}

in lib/plugins/sync/admin.php

but this is rather quick'n'dirty and lost after every upgrade of the plugin.

It would be nice if the sync plugin recognizes when a page or a namespace is read only in the remote wiki and skips locking in this case - because locking isn't necessary when the page can't be edited.

cziehr avatar Nov 10 '19 00:11 cziehr

Thanks for sharing the fix @cziehr. Just to clarify the code that causes the couldn't lock and will skip error is in lines 366-369 of admin.php, which is:

        foreach((array) $data['lockfail'] as $id){
            $this->_listOut($this->getLang('lockfail').' '.hsc($id),'error');
            unset($synclist[$id]);
        }

I'm sure there is a reason that @splitbrain has this section in the code, but it would be good to have the option to skip that check.

For anyone looking for a fix to this (until a code update is made), you can either delete the lines listed above or make the following updates to admin.php (also available in this branch):

        // allow read-only access to the remote wiki
        // the below code causes sync to fail when the remote
        // user only has read access to the remote wiki
        // foreach((array) $data['lockfail'] as $id){
        //     $this->_listOut($this->getLang('lockfail').' '.hsc($id),'error');
        //     unset($synclist[$id]);
        // }

Once the update is made, you can start the synchronization again and should get a pull succeded response for the files.

This is also related to https://github.com/splitbrain/dokuwiki-plugin-sync/issues/51

rwaight avatar Aug 03 '23 20:08 rwaight