aboutsummaryrefslogtreecommitdiffstats
path: root/htdocs
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 /htdocs
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
Diffstat (limited to 'htdocs')
-rw-r--r--htdocs/application/controllers/Api.php6
1 files changed, 4 insertions, 2 deletions
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