mirror of
https://github.com/friendica/friendica
synced 2025-04-25 01:50:11 +00:00
OEmbed and parse_url are now cached in dedicated tables
This commit is contained in:
parent
c4ba035ee3
commit
d5e1f33506
6 changed files with 49 additions and 13 deletions
|
@ -13,7 +13,13 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
|
|||
|
||||
$a = get_app();
|
||||
|
||||
$txt = Cache::get($a->videowidth . $embedurl);
|
||||
$r = q("SELECT * FROM `oembed` WHERE `url` = '%s'",
|
||||
dbesc(normalise_link($embedurl)));
|
||||
|
||||
if ($r)
|
||||
$txt = $r[0]["content"];
|
||||
else
|
||||
$txt = Cache::get($a->videowidth . $embedurl);
|
||||
|
||||
// These media files should now be caught in bbcode.php
|
||||
// left here as a fallback in case this is called from another source
|
||||
|
@ -66,8 +72,14 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
|
|||
|
||||
if ($txt[0]!="{")
|
||||
$txt='{"type":"error"}';
|
||||
else //save in cache
|
||||
else { //save in cache
|
||||
$j = json_decode($txt);
|
||||
if ($j->type != "error")
|
||||
q("INSERT INTO `oembed` (`url`, `content`) VALUES ('%s', '%s')",
|
||||
dbesc(normalise_link($embedurl)), dbesc($txt));
|
||||
|
||||
Cache::set($a->videowidth . $embedurl,$txt, CACHE_DAY);
|
||||
}
|
||||
}
|
||||
|
||||
$j = json_decode($txt);
|
||||
|
@ -85,7 +97,7 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
|
|||
// If fetching information doesn't work, then improve via internal functions
|
||||
if (($j->type == "error") OR ($no_rich_type AND ($j->type == "rich"))) {
|
||||
require_once("mod/parse_url.php");
|
||||
$data = parseurl_getsiteinfo($embedurl, true, false);
|
||||
$data = parseurl_getsiteinfo_cached($embedurl, true, false);
|
||||
$j->type = $data["type"];
|
||||
|
||||
if ($j->type == "photo") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue