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

Infinite loop in APIData Source #13

Open
lyubo-slavilov opened this issue Jan 21, 2025 · 1 comment
Open

Infinite loop in APIData Source #13

lyubo-slavilov opened this issue Jan 21, 2025 · 1 comment

Comments

@lyubo-slavilov
Copy link

while (true) {
$data = $this->queryApi($apiOpenResult, $step);
if (empty($data)) break;
$step++;
// Send meta and data
// ...
if (is_array($data) && count($data) > 0) {
if (!$this->metaSent) {
$metaData = $this->metaData;
$row0 = $this->mapRow(array_values($data)[0]);
foreach ($row0 as $key => $value) {
$metaData["columns"][$key] = array(
"type" => $this->guessType($value),
);
}
$this->sendMeta($metaData, $this);
$this->metaSent = true;
$this->startInput(null);
}
foreach ($data as $row) {
$row = $this->mapRow($row);
$this->next($row);
}
}
}

The while loop never ends.
Caused by the check if (is_array($data) && count($data) > 0) which will never be evaluated to true because $data is always a string.

So currently APIDataSource is usless

@lyubo-slavilov
Copy link
Author

lyubo-slavilov commented Jan 21, 2025

The situation is worsening by the fact that this loop will try to query the external API as fast as possible as many times as possible, rendering the APIDataSource to a DOS machine :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant