Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dirty fix to allow syncing from Wikis that remoteuser has no "[root]"… #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,16 +654,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