mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 12:45:55 +00:00
generate a warning if plugin-generated content of HOOK_ARTICLE_BUTTON or _LEFT_BUTTON can't be parsed as valid XML
This commit is contained in:
@@ -14,4 +14,27 @@ class Errors {
|
||||
static function to_json(string $code, array $params = []): string {
|
||||
return json_encode(["error" => ["code" => $code, "params" => $params]]);
|
||||
}
|
||||
|
||||
static function libxml_last_error() : string {
|
||||
$error = libxml_get_last_error();
|
||||
$error_formatted = "";
|
||||
|
||||
if ($error) {
|
||||
foreach (libxml_get_errors() as $error) {
|
||||
if ($error->level == LIBXML_ERR_FATAL) {
|
||||
// currently only the first error is reported
|
||||
$error_formatted = self::format_libxml_error($error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UConverter::transcode($error_formatted, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
|
||||
static function format_libxml_error(LibXMLError $error) : string {
|
||||
return sprintf("LibXML error %s at line %d (column %d): %s",
|
||||
$error->code, $error->line, $error->column,
|
||||
$error->message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user