From 3761e9ee51dca7c4b822303b43f09b165f902b92 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 28 Mar 2020 15:14:40 +0000 Subject: [PATCH 1/2] Issue 8254: Some more fixes for too long data for columns --- src/Model/APContact.php | 16 ++++++++++++++++ src/Model/Term.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 071d935165..7bf76b03b1 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -260,6 +260,22 @@ class APContact // Unhandled from Kroeg // kroeg:blocks, updated + // When the photo is too large, try to shorten it by removing parts + if (strlen($apcontact['photo']) > 255) { + $parts = parse_url($apcontact['photo']); + unset($parts['query']); + $apcontact['photo'] = Network::unparseURL($parts); + + if (strlen($apcontact['photo']) > 255) { + unset($parts['fragment']); + $apcontact['photo'] = Network::unparseURL($parts); + } + + if (strlen($apcontact['photo']) > 255) { + $apcontact['photo'] = substr($apcontact['photo'], 0, 255); + } + } + $parts = parse_url($apcontact['url']); unset($parts['path']); $baseurl = Network::unparseURL($parts); diff --git a/src/Model/Term.php b/src/Model/Term.php index 868f2bf053..84cb1bea7a 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -345,7 +345,7 @@ class Term 'oid' => $item_id, 'otype' => self::OBJECT_TYPE_POST, 'type' => $type, - 'term' => $term, + 'term' => substr($term, 0, 255), 'url' => $link, 'guid' => $item['guid'], 'created' => $item['created'], From 2ba4333f70af1a11d28fd44f86cd35a5a7d78c2a Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 28 Mar 2020 15:18:12 +0000 Subject: [PATCH 2/2] Exchange "part" with "fragment" --- src/Model/APContact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 7bf76b03b1..ec33864f4d 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -263,11 +263,11 @@ class APContact // When the photo is too large, try to shorten it by removing parts if (strlen($apcontact['photo']) > 255) { $parts = parse_url($apcontact['photo']); - unset($parts['query']); + unset($parts['fragment']); $apcontact['photo'] = Network::unparseURL($parts); if (strlen($apcontact['photo']) > 255) { - unset($parts['fragment']); + unset($parts['query']); $apcontact['photo'] = Network::unparseURL($parts); }