@@ -46,7 +46,13 @@ public static function endWithJson($_payload, $code = 200) {
4646
4747 $ payload = self ::getPayload ($ _payload );
4848 $ app ->response ->headers ->set ('Content-Type ' , 'application/json ' );
49- $ app ->halt ($ code , json_encode ($ payload ));
49+ // If the payload is a PaginatedCollection, getPayload() already called
50+ // setStatus() on $app->response (e.g. 206 for partial range, 400 for
51+ // out-of-range start). Respect that status instead of always using 200.
52+ $ effectiveCode = ($ _payload instanceof \API \Core \PaginatedCollection)
53+ ? $ app ->response ->getStatus ()
54+ : $ code ;
55+ $ app ->halt ($ effectiveCode , json_encode ($ payload ));
5056 }
5157
5258 /**
@@ -105,7 +111,7 @@ public static function endWithRSS($_payload, $feed_title = '', $code = 200) {
105111 break ;
106112 }
107113 }
108- if (empty ($ description )) {
114+ if (empty ($ description ) && count ( $ plugin [ ' descriptions ' ]) > 0 ) {
109115 $ description = $ plugin ['descriptions ' ][0 ]['long_description ' ];
110116 }
111117
@@ -160,7 +166,7 @@ public static function makeEndpoint($callable) {
160166 try {
161167 call_user_func_array ($ callable , $ args );
162168 }
163- catch (\Exception $ e ) {
169+ catch (\Throwable $ e ) {
164170 global $ app ;
165171 if (!preg_match ('/^API \\\\Exception/ ' , get_class ($ e ))) {
166172 switch (get_class ($ e )) {
@@ -316,7 +322,8 @@ public static function getRequestLang() {
316322 public static $ config = null ;
317323 public static function getConfig () {
318324 if (!self ::$ config ) {
319- require dirname (__FILE__ ) . '/../../config.php ' ;
325+ $ configFile = getenv ('APP_CONFIG_FILE ' ) ?: dirname (__FILE__ ) . '/../../config.php ' ;
326+ require $ configFile ;
320327 self ::$ config = $ config ;
321328 }
322329 return self ::$ config ;
0 commit comments