Fixes for OEmbed class (#5392)

* Fixes:
- stdClass is clearly an object of `\stdClass`, so let's import it and set it
  as type-hint here
- if $o->type is not found, don't continue

Signed-off-by: Roland Häder <roland@mxchange.org>

* Fix for a fix due to 02:51 a.m. (!) edits ...

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2018-07-17 22:28:20 +02:00 committed by Hypolite Petovan
parent 04b513ba95
commit fd8897851f

View file

@ -20,6 +20,7 @@ use DOMNode;
use DOMText; use DOMText;
use DOMXPath; use DOMXPath;
use Exception; use Exception;
use stdClass;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'mod/proxy.php'; require_once 'mod/proxy.php';
@ -163,11 +164,12 @@ class OEmbed
return $j; return $j;
} }
private static function formatObject($j) private static function formatObject(stdClass $j)
{ {
$embedurl = $j->embedurl; $embedurl = $j->embedurl;
$jhtml = $j->html; $jhtml = $j->html;
$ret = '<div class="oembed ' . $j->type . '">'; $ret = '<div class="oembed ' . $j->type . '">';
switch ($j->type) { switch ($j->type) {
case "video": case "video":
if (isset($j->thumbnail_url)) { if (isset($j->thumbnail_url)) {
@ -326,7 +328,7 @@ class OEmbed
$o = self::fetchURL($url, !self::isAllowedURL($url)); $o = self::fetchURL($url, !self::isAllowedURL($url));
if (!is_object($o) || $o->type == 'error') { if (!is_object($o) || property_exists($o, 'type') && $o->type == 'error') {
throw new Exception('OEmbed failed for URL: ' . $url); throw new Exception('OEmbed failed for URL: ' . $url);
} }