Merge branch 'dev' into 'dev'

Better cached photos processing

See merge request hubzilla/core!1759
This commit is contained in:
Max Kostikov 2019-10-26 12:30:41 +02:00
commit b00db39739

View File

@ -31,12 +31,7 @@ class Photo extends \Zotlabs\Web\Controller {
// NOTREACHED // NOTREACHED
} }
$cache_mode = array( $cache_mode = [ 'on' => false, 'age' => 86400, 'exp' => true, 'leak' => false ];
'on' => false,
'age' => 86400,
'exp' => true,
'leak' => false
);
call_hooks('cache_mode_hook', $cache_mode); call_hooks('cache_mode_hook', $cache_mode);
$observer_xchan = get_observer_hash(); $observer_xchan = get_observer_hash();
@ -144,7 +139,7 @@ class Photo extends \Zotlabs\Web\Controller {
$resolution = 1; $resolution = 1;
} }
$r = q("SELECT uid, photo_usage, display_path FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo), dbesc($photo),
intval($resolution) intval($resolution)
); );
@ -163,13 +158,10 @@ class Photo extends \Zotlabs\Web\Controller {
if($u === PHOTO_CACHE) { if($u === PHOTO_CACHE) {
// Validate cache // Validate cache
if($cache_mode['on']) { if($cache_mode['on']) {
$cache = array( $cache = [ 'status' => false, 'item' => $r[0] ];
'resid' => $photo,
'status' => false
);
call_hooks('cache_url_hook', $cache); call_hooks('cache_url_hook', $cache);
if(! $cache['status']) { if(! $cache['status']) {
$url = html_entity_decode($r[0]['display_path'], ENT_QUOTES); $url = html_entity_decode($cache['item']['display_path'], ENT_QUOTES);
// SSLify if needed // SSLify if needed
if(strpos(z_root(),'https:') !== false && strpos($url,'https:') === false) if(strpos(z_root(),'https:') !== false && strpos($url,'https:') === false)
$url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url); $url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url);