Skip to content
Snippets Groups Projects
Commit 3323ae78 authored by Andrew Dolgov's avatar Andrew Dolgov
Browse files

* sql_bool_to_bool: make parameter nullable

 * errorhandler: don't try to truncate null strings
 * UrlHelper::rewrite_relative: fix undefined offset warnings for URLs
that lack schema/host (data: etc)
parent e7111e4f
No related branches found
No related tags found
No related merge requests found
...@@ -89,8 +89,8 @@ class UrlHelper { ...@@ -89,8 +89,8 @@ class UrlHelper {
} else { } else {
$base_parts = parse_url($base_url); $base_parts = parse_url($base_url);
$rel_parts['host'] = $base_parts['host']; $rel_parts['host'] = $base_parts['host'] ?? "";
$rel_parts['scheme'] = $base_parts['scheme']; $rel_parts['scheme'] = $base_parts['scheme'] ?? "";
if (isset($rel_parts['path'])) { if (isset($rel_parts['path'])) {
......
...@@ -19,7 +19,7 @@ function format_backtrace($trace): string { ...@@ -19,7 +19,7 @@ function format_backtrace($trace): string {
array_push($fmt_args, "[" . truncate_string(json_encode($a), 256, "...")) . "]"; array_push($fmt_args, "[" . truncate_string(json_encode($a), 256, "...")) . "]";
} else if (is_resource($a)) { } else if (is_resource($a)) {
array_push($fmt_args, truncate_string(get_resource_type($a), 256, "...")); array_push($fmt_args, truncate_string(get_resource_type($a), 256, "..."));
} else { } else if ($a) {
array_push($fmt_args, truncate_string($a, 256, "...")); array_push($fmt_args, truncate_string($a, 256, "..."));
} }
} }
......
...@@ -341,7 +341,12 @@ ...@@ -341,7 +341,12 @@
} }
} }
function sql_bool_to_bool(string $s): bool { /** Convert values accepted by tt-rss as true/false to PHP booleans
* @see https://tt-rss.org/wiki/ApiReference#boolean-values
* @param null|string $s null values are considered false
* @return bool
*/
function sql_bool_to_bool(?string $s): bool {
return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment