Fix bug in phototrack

This commit is contained in:
Matthew Exon 2020-01-06 22:12:47 +01:00 committed by Matthew Exon
parent 3859a41118
commit 4d5a68c6a4

View file

@ -103,12 +103,22 @@ function phototrack_photo_use($photo, $table, $field, $id) {
function phototrack_check_field_url($a, $table, $field, $id, $url) { function phototrack_check_field_url($a, $table, $field, $id, $url) {
Logger::info('@@@ phototrack_check_field_url table ' . $table . ' field ' . $field . ' id ' . $id . ' url ' . $url); Logger::info('@@@ phototrack_check_field_url table ' . $table . ' field ' . $field . ' id ' . $id . ' url ' . $url);
$baseurl = $a->getBaseURL(); $baseurl = $a->getBaseURL();
if (strpos($url, $baseurl) !== FALSE) { if (strpos($url, $baseurl) === FALSE) {
return;
}
else {
$url = substr($url, strlen($baseurl)); $url = substr($url, strlen($baseurl));
Logger::info('@@@ phototrack_check_field_url funny url stuff ' . $url . ' base ' . $baseurl); Logger::info('@@@ phototrack_check_field_url funny url stuff ' . $url . ' base ' . $baseurl);
} }
if (strpos($url, '/photo/') !== FALSE) { if (strpos($url, '/photo/') === FALSE) {
$rid = substr($url, strlen('/photo/')); return;
}
else {
$url = substr($url, strlen('/photo/'));
Logger::info('@@@ phototrack_check_field_url more url stuff ' . $url);
}
if (preg_match('/([0-9a-z]{32})/', $url, $matches)) {
$rid = $matches[0];
Logger::info('@@@ phototrack_check_field_url rid ' . $rid); Logger::info('@@@ phototrack_check_field_url rid ' . $rid);
phototrack_photo_use($rid, $table, $field, $id); phototrack_photo_use($rid, $table, $field, $id);
} }