aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2023-01-11 16:05:06 +0100
committerDaniel Lange <DLange@git.local>2023-01-11 16:05:06 +0100
commit6d21b208b9cfae0941bebf59b39ee04f6002b4f9 (patch)
tree43fd71c7464eaecba172810d000dc2e426bd8d94
parent39154d99acf0359638be5d5efd51e44f5b803e4b (diff)
downloadstikked-fit-6d21b208b9cfae0941bebf59b39ee04f6002b4f9.tar.gz
stikked-fit-6d21b208b9cfae0941bebf59b39ee04f6002b4f9.tar.bz2
stikked-fit-6d21b208b9cfae0941bebf59b39ee04f6002b4f9.zip
Fix the API in case of empty arrays and fix the /langs endpoint
-rw-r--r--README.md1
-rw-r--r--htdocs/application/controllers/Api.php6
2 files changed, 5 insertions, 2 deletions
diff --git a/README.md b/README.md
index 72f3220..d7c9253 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,7 @@ Copy your htdocs/application/stikked.php config file away. Upload the new versio
### Version 0.15.0-fit:
+* Fix some issues in the API [Daniel Lange/FIT]
* Make replying more robust in case of expired pastes [Daniel Lange/FIT]
* Fix the bootstrap theme [Daniel Lange/FIT]
* Fix captcha_helper for PHP 8.0+ compliance [Daniel Lange/FIT]
diff --git a/htdocs/application/controllers/Api.php b/htdocs/application/controllers/Api.php
index 74aac22..948ed24 100644
--- a/htdocs/application/controllers/Api.php
+++ b/htdocs/application/controllers/Api.php
@@ -132,7 +132,7 @@ class Api extends Main
}
$this->load->model('pastes');
$pastes = $this->pastes->getLists('api/recent');
- $pastes = $pastes['pastes'];
+ $pastes = $pastes['pastes'] ?? [];
$data = array();
foreach ($pastes as $paste) {
$data[] = array(
@@ -158,7 +158,7 @@ class Api extends Main
}
$this->load->model('pastes');
$pastes = $this->pastes->getTrends('api/trending', 2);
- $pastes = $pastes['pastes'];
+ $pastes = $pastes['pastes'] ?? [];
$data = array();
foreach ($pastes as $paste) {
$data[] = array(
@@ -180,6 +180,8 @@ class Api extends Main
}
$languages = $this->languages->get_languages();
+ // remove the 0 --- divider between favorite languages and the rest
+ unset($languages["0"]);
echo json_encode($languages);
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy