Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Fixed bugs when there are no queries in the query phrasebook and remo…
Browse files Browse the repository at this point in the history
…ve last empty line from export API

Fixes #1
  • Loading branch information
Hipska committed Jan 5, 2018
1 parent c542403 commit d8cc8fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/Itop/RestApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function doExport($query, $no_localize = 1, $fields = '')
$export = $fields = array();
$tempFile = new \SplTempFileObject();
$tempFile->fwrite($response);
$tempFile->setFlags(\SplFileObject::READ_CSV);
$tempFile->setFlags(\SplFileObject::READ_CSV | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
$tempFile->setCsvControl(',','"','"');

foreach ($tempFile as $key => $row)
Expand Down Expand Up @@ -164,7 +164,7 @@ public function doRestCall($operation, $data = array())
throw new Exception('Parsing JSON result failed: ' . $message);
}

if ($response->code != 0)
if (!isset($response->code) or $response->code != 0)
{
throw new Exception($response->message);
}
Expand Down
2 changes: 2 additions & 0 deletions library/Itop/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static function enumQueries($resourceName)
'key' => 'SELECT QueryOQL WHERE fields != ""',
'output_fields' => 'name',
));

if(!isset($response->objects)) return array();

$queries = array();
foreach($response->objects as $object)
Expand Down

0 comments on commit d8cc8fe

Please sign in to comment.