aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2018-11-09 22:20:41 +0100
committerMax Kostikov <max@kostikov.co>2018-11-09 22:20:41 +0100
commit32873ce70d7ee22fd95afa66f2c70637aaeef642 (patch)
tree01a3733c05c584451f79592807d4d5202c5be172
parentdc59561a95f8354209f423a07bfd7fb3381f3633 (diff)
downloadvolse-hubzilla-32873ce70d7ee22fd95afa66f2c70637aaeef642.tar.gz
volse-hubzilla-32873ce70d7ee22fd95afa66f2c70637aaeef642.tar.bz2
volse-hubzilla-32873ce70d7ee22fd95afa66f2c70637aaeef642.zip
Preserve received image modification date on caching
-rw-r--r--include/photo/photo_driver.php27
1 files changed, 16 insertions, 11 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 12465c794..a4866bb60 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -350,8 +350,7 @@ abstract class photo_driver {
$p['allow_gid'] = (($arr['allow_gid']) ? $arr['allow_gid'] : '');
$p['deny_cid'] = (($arr['deny_cid']) ? $arr['deny_cid'] : '');
$p['deny_gid'] = (($arr['deny_gid']) ? $arr['deny_gid'] : '');
- $p['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
- $p['edited'] = (($arr['edited']) ? $arr['edited'] : $p['created']);
+ $p['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
$p['title'] = (($arr['title']) ? $arr['title'] : '');
$p['description'] = (($arr['description']) ? $arr['description'] : '');
$p['photo_usage'] = intval($arr['photo_usage']);
@@ -365,13 +364,15 @@ abstract class photo_driver {
if(! intval($p['imgscale']))
logger('save: ' . print_r($arr,true), LOGGER_DATA);
- $x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1",
+ $x = q("select id, created from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1",
dbesc($p['resource_id']),
intval($p['uid']),
dbesc($p['xchan']),
intval($p['imgscale'])
);
+
if($x) {
+ $p['created'] = (($x['created']) ? $x['created'] : $p['edited']);
$r = q("UPDATE photo set
aid = %d,
uid = %d,
@@ -427,6 +428,7 @@ abstract class photo_driver {
);
}
else {
+ $p['created'] = (($arr['created']) ? $arr['created'] : $p['edited']);
$r = q("INSERT INTO photo
( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, os_storage, filesize, imgscale, photo_usage, title, description, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
@@ -464,11 +466,6 @@ abstract class photo_driver {
-
-
-
-
-
/**
* Guess image mimetype from filename or from Content-Type header
*
@@ -650,9 +647,8 @@ function import_xchan_photo($photo,$xchan,$thing = false,$force = false) {
}
}
- else {
+ else
$photo_failure = true;
- }
if(! $photo_failure && $result['return_code'] != 304) {
$img = photo_factory($img_str, $type);
@@ -680,7 +676,15 @@ function import_xchan_photo($photo,$xchan,$thing = false,$force = false) {
else
$photo_failure = true;
- $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'imgscale' => 4);
+ $p = array(
+ 'xchan' => $xchan,
+ 'resource_id' => $hash,
+ 'filename' => basename($photo),
+ 'album' => $album,
+ 'photo_usage' => $flags,
+ 'imgscale' => 4,
+ 'edited' => $modified
+ );
$r = $img->save($p);
@@ -721,6 +725,7 @@ function import_xchan_photo($photo,$xchan,$thing = false,$force = false) {
$modified = gmdate('Y-m-d H:i:s', filemtime($default));
}
+ logger('HTTP code: ' . $result['return_code'] . '; modified: ' . $modified . '; failure: ' . ($photo_failure ? 'yes' : 'no') . '; URL: ' . $photo, LOGGER_DEBUG);
return(array($photo,$thumb,$micro,$type,$photo_failure,$modified));
}