mirror of
https://github.com/friendica/friendica
synced 2025-04-25 16:30:10 +00:00
Suppress XML logging of errors
This commit is contained in:
parent
ebb96faedd
commit
f521689ced
7 changed files with 32 additions and 24 deletions
|
@ -433,18 +433,26 @@ class XML
|
|||
}
|
||||
}
|
||||
|
||||
public static function parseString($s, $strict = true)
|
||||
/**
|
||||
* Parse XML string
|
||||
*
|
||||
* @param string $s
|
||||
* @param boolean $suppress_log
|
||||
* @return Object
|
||||
*/
|
||||
public static function parseString(string $s, bool $suppress_log = false)
|
||||
{
|
||||
// the "strict" parameter is deactivated
|
||||
libxml_use_internal_errors(true);
|
||||
|
||||
$x = @simplexml_load_string($s);
|
||||
if (!$x) {
|
||||
Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]);
|
||||
foreach (libxml_get_errors() as $err) {
|
||||
Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]);
|
||||
if (!$suppress_log) {
|
||||
Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]);
|
||||
foreach (libxml_get_errors() as $err) {
|
||||
Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]);
|
||||
}
|
||||
Logger::debug('Erroring XML string', ['xml' => $s]);
|
||||
}
|
||||
Logger::debug('Erroring XML string', ['xml' => $s]);
|
||||
libxml_clear_errors();
|
||||
}
|
||||
return $x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue