Avoid SQL errors because of existing entries
This commit is contained in:
parent
3a819e3630
commit
26e1c4d458
2 changed files with 11 additions and 5 deletions
|
@ -75,8 +75,11 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
|
||||||
else { //save in cache
|
else { //save in cache
|
||||||
$j = json_decode($txt);
|
$j = json_decode($txt);
|
||||||
if ($j->type != "error")
|
if ($j->type != "error")
|
||||||
q("INSERT INTO `oembed` (`url`, `content`, `created`) VALUES ('%s', '%s', '%s')",
|
q("INSERT INTO `oembed` (`url`, `content`, `created`) VALUES ('%s', '%s', '%s')
|
||||||
dbesc(normalise_link($embedurl)), dbesc($txt), dbesc(datetime_convert()));
|
ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'",
|
||||||
|
dbesc(normalise_link($embedurl)),
|
||||||
|
dbesc($txt), dbesc(datetime_convert()),
|
||||||
|
dbesc($txt), dbesc(datetime_convert()));
|
||||||
|
|
||||||
Cache::set($a->videowidth.$embedurl,$txt, CACHE_DAY);
|
Cache::set($a->videowidth.$embedurl,$txt, CACHE_DAY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,11 @@ function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = tr
|
||||||
|
|
||||||
$data = parseurl_getsiteinfo($url, $no_guessing, $do_oembed);
|
$data = parseurl_getsiteinfo($url, $no_guessing, $do_oembed);
|
||||||
|
|
||||||
q("INSERT INTO `parsed_url` (`url`, `guessing`, `oembed`, `content`, `created`) VALUES ('%s', %d, %d, '%s', '%s')",
|
q("INSERT INTO `parsed_url` (`url`, `guessing`, `oembed`, `content`, `created`) VALUES ('%s', %d, %d, '%s', '%s')
|
||||||
dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed), dbesc(serialize($data)), dbesc(datetime_convert()));
|
ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'",
|
||||||
|
dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed),
|
||||||
|
dbesc(serialize($data)), dbesc(datetime_convert()),
|
||||||
|
dbesc(serialize($data)), dbesc(datetime_convert()));
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue