Skip to content

Commit

Permalink
Dirty fix to allow syncing from Wikis that remoteuser has no "[root]"…
Browse files Browse the repository at this point in the history
… access

Please see splitbrain#56
  • Loading branch information
eduardomozart committed Nov 19, 2021
1 parent 7efd499 commit c118283
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,45 @@ function _getSyncList($type='pages'){
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
}else{
$ok = $this->client->query('wiki.getAttachments',$ns,
if(!empty($ns)){
$ok = $this->client->query('wiki.getAttachments',$ns,
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
}else{
$ok = $this->client->query('dokuwiki.getPagelist',$ns,
array('depth' => (int) $this->profiles[$no]['depth'],
'hash' => true));
if($ok){
$remotepages = $this->client->getResponse();
foreach ($remotepages as $item) {
if((int) $this->profiles[$no]['depth'] == 0 && strpos($item['id'],':')) continue;
// echo "Trying to sync: " . $item['id'];
$ok = $this->client->query('wiki.getAttachments',$item['id'],
array('depth' => ((int) $this->profiles[$no]['depth'] > 0 ? 1 : 0),
'hash' => true));
if($ok){
if(!isset($remote)) $remote = array();
$remote = array_merge($remote, $this->client->getResponse());
}else{
if(strpos($this->client->getErrorMessage(), '403')) {
// 'remoteuser' has access to the page, but receives a 403 Forbidden
// Probably Media namespace is empty or doesn't exists
$ok = true;
}else{
// echo " [FAIL]";
break;
}
}
}
}
}
}
if(!$ok){
msg('Failed to fetch remote file list. '.
$this->client->getErrorMessage(),-1);
return false;
}
$remote = $this->client->getResponse();
if(!isset($remote)) $remote = $this->client->getResponse();
// put into synclist
foreach($remote as $item){
$list[$item['id']]['remote'] = $item;
Expand Down

0 comments on commit c118283

Please sign in to comment.