mirror of
https://github.com/friendica/friendica
synced 2025-04-25 07:50:10 +00:00
Avoid "Trying to get property of non-object"
This commit is contained in:
parent
3e797547a3
commit
7d6933c898
4 changed files with 68 additions and 54 deletions
|
@ -431,4 +431,19 @@ class XML
|
|||
}
|
||||
return $x;
|
||||
}
|
||||
|
||||
public static function getFirstNodeValue($xpath, $element, $context = null)
|
||||
{
|
||||
$result = $xpath->evaluate($element, $context);
|
||||
if (!is_object($result)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$first_item = $result->item(0);
|
||||
if (!is_object($first_item)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $first_item->nodeValue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue