Skip to content

Commit

Permalink
More robust calling of file_get_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
chrode committed Jul 24, 2024
1 parent ea78222 commit 879a0fd
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Classes/Controller/BibliografieController.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,30 @@ public function getApiResults($action='items') : array

public function request($url, $requestCount=0)
{
$json = file_get_contents($url);
$data = json_decode($json, true);
$this->reIndexArray($data);

if ($requestCount==0 && count($data)==$this->settings['zotero']['limit']) {
// load only one page more
$url .= '&start='.$this->settings['zotero']['limit'];
$dataNext = $this->request($url, 1);
$data = array_merge($data, $dataNext);
$data = '',

if ($this->settings['debug'] == true) {
DebugUtility::debug($url, 'Debug: ' . __FILE__ . ' in Line: ' . __LINE__ . ' Function: '. __FUNCTION__);
}

$json = @file_get_contents($url);

if($json !== FALSE) {
$data = json_decode($json, true);
$this->reIndexArray($data);

if ($requestCount==0 && count($data)==$this->settings['zotero']['limit']) {
// load only one page more
$url .= '&start='.$this->settings['zotero']['limit'];
$dataNext = $this->request($url, 1);
$data = array_merge($data, $dataNext);
}
}

if ($this->settings['debug'] == true) {
DebugUtility::debug($data, 'Debug: ' . __FILE__ . ' in Line: ' . __LINE__ . ' Function: '. __FUNCTION__);
}

return $data;
}

Expand Down

0 comments on commit 879a0fd

Please sign in to comment.