aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-13 10:28:06 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-13 10:28:06 +0200
commit7465c798847198238a991b302e8f6537896b9c3e (patch)
tree2eeaef70d93c6adadf49be78394f146bf393dd88
parent769195fcff8623cac748df8f32a92e4cfd22e0a5 (diff)
downloadvolse-hubzilla-7465c798847198238a991b302e8f6537896b9c3e.tar.gz
volse-hubzilla-7465c798847198238a991b302e8f6537896b9c3e.tar.bz2
volse-hubzilla-7465c798847198238a991b302e8f6537896b9c3e.zip
optimise oembed pdf processing so we do not actually load the content, which could cause performance issues. ported from zap.
-rwxr-xr-xinclude/oembed.php31
1 files changed, 16 insertions, 15 deletions
diff --git a/include/oembed.php b/include/oembed.php
index 426197c5f..ee9e57c3f 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -1,6 +1,6 @@
<?php /** @file */
-use Zotlabs\Lib as Zlib;
+use Zotlabs\Lib\Cache;
function oembed_replacecb($matches){
@@ -133,7 +133,6 @@ function oembed_fetch_url($embedurl){
}
}
-
$txt = null;
// we should try to cache this and avoid a lookup on each render
@@ -143,10 +142,22 @@ function oembed_fetch_url($embedurl){
$furl = ((local_channel() && $zrl) ? zid($embedurl) : $embedurl);
- if($action !== 'block') {
- $txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $furl);
+ if($action !== 'block' && (! get_config('system','oembed_cache_disable'))) {
+ $txt = Cache::get('[' . App::$videowidth . '] ' . $furl);
}
+
+ if(strpos(strtolower($embedurl),'.pdf') !== false) {
+ $action = 'allow';
+ $j = [
+ 'html' => '<object data="' . $embedurl . '" type="application/pdf" style="width: 100%; height: 300px;"></object>',
+ 'title' => t('View PDF'),
+ 'type' => 'pdf'
+ ];
+ // set $txt to something so that we don't attempt to fetch what could be a lengthy pdf.
+ $txt = EMPTY_STR;
+ }
+
if(is_null($txt)) {
$txt = "";
@@ -215,20 +226,10 @@ function oembed_fetch_url($embedurl){
// save in cache
if(! get_config('system','oembed_cache_disable'))
- Zlib\Cache::set('[' . App::$videowidth . '] ' . $furl, $txt);
+ Cache::set('[' . App::$videowidth . '] ' . $furl, $txt);
}
- if(strpos(strtolower($embedurl),'.pdf') !== false) {
- $action = 'allow';
- $j = [
- 'html' => '<object data="' . $embedurl . '" type="application/pdf" style="width: 100%; height: 300px;"></object>',
- 'title' => t('View PDF'),
- 'type' => 'pdf'
- ];
-
- }
-
if(! $j) {
$j = json_decode($txt,true);
}