Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(kb): update migration script to get all pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret committed Nov 7, 2017
1 parent cddc744 commit 0f26cdf
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions www/class/centreon-knowledge/wikiApi.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,24 @@ public function getAllPages()
'format' => 'json',
'action' => 'query',
'list' => 'allpages',
'aplimit' => '1000'
'aplimit' => '10'
);

curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postfields);
$result = curl_exec($this->curl);
$result = json_decode($result);

$pages = array();
foreach ($result->query->allpages as $page) {
$pages[] = $page->title;
}
do {
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postfields);
$result = curl_exec($this->curl);
$result = json_decode($result);

foreach ($result->query->allpages as $page) {
$pages[] = $page->title;
}

// Get next page if exists
if (isset($result->{'query-continue'}->allpages->apcontinue)) {
$postfields['apfrom'] = $result->{'query-continue'}->allpages->apcontinue;
}
} while (isset($result->{'query-continue'}->allpages->apcontinue));

return $pages;
}
Expand Down

0 comments on commit 0f26cdf

Please sign in to comment.